my faceChris Foley is a computer programming enthusiast. He loves exploring new programming languages and crafting nice solutions. He lives in Glasgow, Scotland and works as a software developer.

Code Review

There is a design and it is incredible. It exists in documents and on whiteboards and in some unit tests but mainly it exists in my head. It's a marvel of software engineering, both efficient and elegant. It is instantly updated as my understanding of the problem evolves or as the requirements change or as my original assumptions are dashed in the face of feature requests.

The code is slow and sluggish by comparison. It doesn't stand a chance. It's as flexible and as extensible as I can make it but changes are made by hand. By the time it would be painstakingly sculpted into its new form, the mind has moved on to a different, better place and the direction has already changed.

And so, the design darts from place to place and the code trundles on never fully achieving the latest design and never fully excising the previous. It is a bastardisation of the ideal, riddled with legacy from a stupider, more ignorant self.

In one simple project, graph theory idealised the domain and some simple, well-known traversal algorithms solved the problem. To the demise of the design, the program was useful to others and the feature requests flooded in. Individually they were easy to add but together the program became a behemoth with data structures and algorithms and aspects desperately clinging onto and strangling the increasingly fragile and decreasingly elegant remnants of the original code.

Do not mistake me. Refactoring was done, injection was sought, code standards and naming conventions were upheld. But indirection (or misdirection) confused and obfuscated. Dead code, difficult to detect with the chosen tooling, weaved its rotten tendrils through live code. It stifled flexibility and sapped maintenance effort.

But all is not lost for there is a new design. All the features are perfectly balanced around a new, all singing, all dancing data structure. The original algorithm is still in there. It has pride of place as the most used and most useful feature. It has been nourished out of its fragility and it's code reads (or will read) like a poem once again. But it is just one feature.

Today I'll be adding something new. As I do, I'll take my scalpel to the old code and take the first small step towards the new design. I'm excited by the new direction and am eager to show off the brilliance of the design. But I know that before the old code is completely cleaned up I'll have a newer, better, more exciting design to work towards and the cycle will continue.

05 February 2015