Metaphors may be a good way of getting to grips with a new domain. It allows you to imagine the behavior of something that you don’t quite understand (yet) in terms of something with which you are quite familiar. That’s were it should stop. I hate metaphors that extend beyond their purpose. Once I have a good enough understanding, I drop the metaphor. My reason is simple. Metaphors force me to do a lot of energy sapping context switching.
Technical debt is one of those metaphors that have been extended so far, that it is believed by many to be something tangible. Let’s get real here: Technical debt does not exist. It is just a metaphor for us to realise that our code base may cost us more money than it should, and that is a future view. Sometimes our metaphors become euphemisms, and then it is dangerous. When it comes to technical debt, the less I think of code problems as debt the more I am able to face the problems head on.
Ironically, I did a talk recently on dealing with technical debt. My fundamental position is simple. Either your code base has things that exist as a result of broken principles or it does not. The more principles you break, the more potential problems you have in your code. It is not a problem right now, but it may be a problem in the future. This future can be a minute away when I run my next test or a year away. If the future is infinitely far away, then it is not a problem at all.
My first prize is to not break principles, so I don’t create potential problems. My second prize is to deal with real problems and just leave the potential problems for the future.
(Warning: I’m drifting into my enlightenment self-reflection, so feel free to stop reading now.)
If I am part of the exploration that is looking for a solution (living in the moment and not outside it as an observer), then I should be aware of principles that I am breaking and I should change course immediately. If I am part of the exploration that is dealing with the potential problem that is now a real problem, than I need to understand the principle that was broken and fix the problem by restoring the principle. Restoring the principle could mean going on a search for the right solution to the original problem, not just trying to fix the problem that is a result of breaking a principle. This problem that broke the principle may just be the wrong solution that we thought was the right solution because we ignored our principles in the first place.
Hmmm, that’s an interesting thought. Karen Greaves asked me if a re-write can be justified and I mumbled something about technology, etc. What tripe! Now I think I’ve just reflected on when a rewrite is justified. When refactoring will not fix the broken principle, then the right solution was never discovered in the first instance. That is also what I mean when I say that clean code is necessary by not sufficient. At factor10, we call this a radical makeover. Radical makeovers are a viable way of getting rid of real problems, and restoring principles.
Heck! This blog post is less about technical debt metaphors than I thought. Oh well, the ride on this journey never stops.
By the way, a huge thank you to Steve for helping me realise that all problems come from breaking principles, in code and in life.