This Thursday and Friday I had a glorious pleasure to partake in OnShift company hackathon – an event intended to make a difference in the lives of my coworkers. Improve processes, put tools in place to improve quality and product delivery speed, automate out the headache. I harbored my particular idea for a feature for several weeks now, so I got to build it almost from scratch. The fun challenge is that I have been Python developer whole of 3 weeks professionally at this point.
As I was standing in front of this deep chasm between model and front end – thinking up the engine I needed to build – it came to me that I have no choice but to go with TDD.
Started off by establishing basics for possible correct and incorrect data format and potential Exception handling as a pattern in the system. Slowly built up the initial data format and refactored tests and initial specifications as I ran into limitations of the JSON framework.
As I was going through the data reflections of models in a complex ORM system, I was building ever so incremental test cases to take me to my goal. Each step had to be verified for sanity: there was a result I wanted to accomplish, there was a piece of code that I assumed would produce this result, and then there was a reality of running that test. Often times the results would be dramatically different from what I expected. That being said, as the night grew darker the deep and shallow copies became more obvious. Tuples became tools of the trade instead of annoying relatives that were always buzzing around.
And here it was, first string of JSON parsed. Now it is time to introduce variable engine. It appears to be my trademark – creating engines with some rudimentary variable management in it’s DSL. I constructed and refactored a concise variable management mechanism that is capable of parsing and retrieving variety of complex values in a stored structure.
Next up full on script processing toolset and ability to reflect into the full on ORM model. A number of snags were discovered there, among them variation of ORM model objects and their behavior as well as simple ability to locate those objects in the first place.
Last touch that was happening at 5:00 AM was actual ability to pass this data from client side to the controller endpoint. This was an odd exercise due to my lack of knowledge and MVC framework’s odd limitations. I had to pass out for about an hour since there was no way out of that confusing hell.
An hour of sleep, shower and a drive to work later I was ready to hack the project anew. Set along side my co-workers who were just as dazed from lack of sleep and perpetual mental battle as I was. Asking for assistance and direction was not terribly useful. While suggestions were reasonably helpful context switching was failing as peopled were pushing their projects across the finish line.
I realized that I should simply go with the flow and make piece with FormData that the framework was insisting on. Once I went that route I got my precious data into controller and the rest of the well tested code proceeded to work and ingest all that I threw at it.
Now for beautification before showing it off. I grabbed this wonderful code editing control called ace from the folks at Cloud 9. Nothing like a bit of flare and user experience to get things rolling. Sadly I was not able to wrangle it into a relative position as I had only 30 min to get done before submission and presentation.
Folks gathered in a large conference room and we were going through each person presenting their individual or group work. Each person was given 5 minutes and if they ran over their time they were shot by a Nerf gun. Most of the folks got fired at which was kind of amusing. Being a trained presenter I fit into my time and was able to show a live demo of my product. I did not get an award, but based on my earlier sales pitch and a great general interest in the feature I anticipate to make it out into GenPop with in the near future.