Friday, November 29, 2013

Code Complete

If debugging is the process of removing software bugs, then programming must be the process of putting them in. - Edsger Dijkstra

I've basically achieved code complete with Episode.Next. It's a feeling of joy that it's all working, but also I'm not quite sure what to do next. What an interesting sign that I got the entire basic app to work in 1-2 days, and then spend the next 3-4 months making performance improvement after performance improvement to it. I have on performance improvement left I could do: change the synching code to use web workers. It's so smooth and fast now, I'm not sure there is any point.

The single best thing I did in the architecture was to abandon doing everything directly in the browser and move a chunk of processing up to Google App Engine. It let me do a ton of optimizations to TheTVDB API that turned into super-fast optimizations. What did I do?

  • Stripped out all the XML meta-data I didn't use.
  • Allow APIs that would strip out other unneeded elements dynamically. If I was just trying to find a new episode, they were no reason to return the XML for all the episodes that I had already watched.
  • Updated all the browser caching of images to cache for 1-year
  • MemCache everything!

I've been surprised just how easy everything was to do. Using Spring MVC and the latest version of Java, everything was trivial. Need to make a JSON API? Just add Jackson in the build. Need to minimize the Javascript? Just add YUI Compression. Need to MemCache? Just add a few lines of JCache code into a Spring Singleton. Everything I wanted to do was just one StackExchange answer away. I was amazed.