Posts

An interesting Interview Question: Fibonacci Sequence

Image
Write a function to calculate the nth Fibonacci Sequence is a common interview question and often the solution is something like   int Fib(int n) {    if(n < 1) return 1;    return Fib(n-1) + Fib(n-2); }   The next question is to ask for n=100, how many items will be on the stack . The answer is not 100 but actually horrible! It is closer to 2^100. take the first call – we start a stack on Fib(99) and one on Fib(98). There is nothing to allow Fib(99) to borrow the result of Fib(98).  So one step is two stack items to recurse.  Each subsequent call changes one stack item into 2 items.   For example 2 –> call [Fib(1), Fib(0)] 3 –> calls [ Fib(2)->[Fib(1), Fib(0)], Fib(1) –> Fib(0) ] 4 –> calls [ Fib(3)->[[[ Fib(2)->[Fib(1), Fib(0)], Fib(1) –> Fib(0) ]], Fib(2)->[Fib(1), Fib(0)], Fib(1) –> Fib(0) ] Missing this issue is very often seen with by-rote developers (who are excell...

Apple Store Passbook UML Diagrams and Error Messages

Image
While working on a recent project, a major stumbling block was a lack of clear documentation of what happened where. This was confirmed when I attempted to search for some of the messages returned to the Log REST points by iPhone.. There were zero hits!     In terms of a Store Card, let us look at the apparent Sequence Diagram     Log Errors Messages Seen and Likely Meaning Passbook Inactive or Deleted or some one changed Auth Token [2016-08-28 11:57:01 -0400] Unregister task (for device ceed8761e584e814ed4fe73cbb334ee9, pass type pass.com.reddwarfdogs.card.dev, serial number 85607BFE98D91A-765F7B05-D5E4-4B32-B16D-69C2038EF522; with web service url https://llc.reddwarfdogs.com/passbook) encountered error: Authentication failure [2016-08-28 20:44:25 +0700] Register task (for device 19121d6b570b31a3fa56dbd45411c933, pass type pass.com.reddwarfdogs.card.dev, serial number 85607BFE98D91A-765F7B05-D5E4-4B32-B16D-69C2038EF522; with web...

Solving PushSharp.Apple Disconnect Issue

While doing a load test of a new Apple Passbook application, I suddenly saw some 200K transmissions errors from my WebApi application. Searching the web I found that a “high” rate of connect/disconnect to Apple Push Notification Service being reported as causing APNS to do a forced disconnect.   While Apple does have a limit (very very high) on the number of notifications before they will refuse connections for an hour, the limit for connect/disconnect is much lower. After some playing around a bit I found that if I persisted the connection via a static, I no longer have this issue.   Below is a sample of the code. Note : we disconnect and reconnect whenever an error happens (I have not seen an error yet)    using Newtonsoft.Json.Linq; using PushSharp.Apple; using System; using System.Collections.Generic; using System.Security.Cryptography.X509Certificates; using System.Text; namespace RedDwarfDogs.Passbook.Engine.Notification { ...

Taking Apple PkPasses In-House–Working Notes

This year I had a explicit, yet vague, project assigned to me: Move our Apple PkPass from a third party provider to our own internal system. The working environment was the Microsoft Stack with C# and a little googling found that the first 90% of the work could be done by nuget, namely: Install-Package dotnet-passbook Install-Package PushSharp Created a certificate file on the apple developer site and we are done … easy project… not quite   Unfortunately both in-house expertise and 3rd part expertise involved in the original project had moved on. Welcome to reverse engineering black boxes.   The Joy of Certificates! Going to http://www.apple.com/certificateauthority/   open a can of worms. The existing instructions assumed you have a Mac not Windows 10. The existing instructions found on the web( https://tomasmcguinness.com/2012/06/28/generating-an-apple-ios-certificate-using-windows/ )  broke due to some change with Windows or Apple in April ...

One Migration Strategy to Microservices

Image
The concepts of microservices is nice, but if you have a complex existing system the path is neither obvious or easy. I have seen Principal Architects throw up their hands and persuade the business that we need to build a new replacement system and that the old system is impossible to work with. This path tends to lead into overruns and often complete failures – I have recently seen that happen at a firm: “Just one year needed to deliver…” and three years later it was killed off because it had not been delivered.  The typical reported in industry literature statistics of 80—90% failure are very believable.   Over decades, I have seen many failrues (usually on the side lines).  On the other hand, for a planned phrase migration I have seen repeated success. Often success or failure seem to be determined by the agile-ness of the management and technical leads coupled with the depth of analysis before the project start. Unfortunately deep analysis ends up with a waterfal...

Theory about Test Environments

Often my career has faced dealing with an arbitrary environment to test in. This environment preceded my arrival, and often was still there at my departure with many developers became fatalistic towards this arbitrary environment.  This is not good.   The Rhetorical Goal Recomposed “We use our test environment to verify that our code changes will work as expected” While this assures upper management, it lacks specifics to evaluate if the test environment is appropriate or complete. A more objective measurement would be: The code changes perform as specified at the six-sigma level of certainty. This then logically cascades into sub-measurements: A1: The code changes perform as specified at the highest projected peak load for the next N year (typically 1-2) at the six-sigma level of certainty. A2: The code changes perform as specified on a fresh created (perfect) environment  at the six-sigma level of certainty. A3: The code changes perform as s...

The sad state of evidence based development management patterns

I have been in the development game for many decades. I did my first programs using APL/360 and Fortran ( WatFiv ) at the University of Waterloo, and have seen and coded a lot of languages over the years (FORTH, COBOL, Asm, Pascal, B,C, C++, SAS, etc).   My academic training was in Operations Research – that is mathematical optimization of business processes . Today, I look at the development processes that I see and it is dominantly “fly by the seats of the pants”, “everybody is doing it” or “academic correctness”. I am not talking about waterfall or agile or scrum. I am not talking about architecture etc. Yet is some ways I am. Some processes assert Evidence Based Management , yet fails to deliver the evidence of better results. Some bloggers detail the problems with EBM.  A few books attempt to summarize the little research that has occurred, such as "Making Software: What Really Works and Why we Believe It"   As an Operation Research person, I woul...