Coswell Productions

Actually Throwing One Away

Most programmers have heard about the idea that the first version of any system design will, consciously or not, be thrown away, once the lessons of the first system have been learned through construction. I've been going through that particular process lately and I'm going to put down some of the internal and external observations I've made throughout the first part of a multi-week process.

In the first iteration of this particular project, I was just getting back into Ruby, and I knew this project was going to be primarily a learning experience. However, once the code actually ended up in production use, I was (of course) reluctant to go and rework the internal structure for fear of missing some vital encapsulated knowledge from the first iteration, as I did discover a lot when working on it. This was my first fear.

I had come back to Ruby primarily out of my disillusionment with developing in PHP. While the tools available to PHP programmers to test & analyze code were getting more and more sophisticated with each iteration, I always found myself writing more lines of code to support tests than the lines of actual code tests. So when I came back to Ruby I discovered tools like RSpec, reek, rcov, and Cucumber, and I went nuts. After a while, though, getting 100% coverage and low reek scores were not actually improving the structure of my code -- only the superficial parts of it. Too-long methods, tight coupling between components, and other signs of poor design and unmaintainability started to creep in, and I became scared to touch this fragile structure I've built, for fear of it all coming crumbling down and necessitating that rebuild anyay.

In between the time of the first commit and the moment I found a rewrite necessary, I had also learned a great deal about the tools I was using. After a year, my tests were getting tighter, my design skills were improving, I was decoupling where necessary, and I understood more of the performance issues that plague Ruby software in particular. The new code I had put into this project was shiny and wonderful in comparison to the bit-rot it was sitting next to. Eventually, when a particular feature started to become too problematic when using this older code, I decided to get over my fears and declare that enough was enough. I needed a rewrite.

When I decided to rework this project, I started with a small part I could easily extract out.

See what else is here...