You watched the videos, read the books and now was ready to start S.O.L.I.D.-ifying their code.
Monday morning, you fire up your favorite IDE and prepare to start writing beautiful, singly responsible and properly abstracted software.
But, unbeknownst to you…you had crossed over into the
Twilight Zone real world!
You knew that the first step of any major refactor (that didn’t already have unit tests) was to write unit tests. This proved difficult however. The existing code was fraught with dependencies and it was difficult to find a good place to start.
It was difficult to wriggle new changes in to the existing code without taking on the taint of it. New classes looked alright, but they stuck out like a sore thumb and it was difficult to modularize the existing code. Much like the dreaded hydra, every abstraction begged for two more.
You lean in to your changes, adding more and more interfaces pushing those dependencies out to the edges. You know this is the right thing to do, you can feel it in your bones.
But the more your pristine gold-plated code collided and colluded with the foul old corrupted code, the uglier things got. Further and further down the rabbit hole you went.
Finally, you began to doubt yourself. Are you even making things better? Or are you just adding to the bizarre pile, making it even more complicated and weird?
Ugh, then you notice the clock. This has taken too long already and there is no end in sight.
You stash your changes, never to be seen again.
Things looked so clean cut and obvious in the book. You felt like you really understood things, so what went wrong?
Well, nothing went wrong per say. This kind of thing happens all the time! You underestimated the depth of the problem and the complexity of the solution.
You understood the problems, and how the solutions addressed them. However, you lacked the requisite skill to divide the solution into manageable chunks so that you could realistically achieve your goal.
I took the inspiration for this post from Sung Kim and The Story of JAM, and One of my favorite web comics about mastering programming. I thought it would be fun to write a fictional Twilight Zone-esque tale that attempted to exemplify a point.
Hope you enjoyed!