Chris Oldwood from The OldWood Thing
One of my most â€œsuccessfulâ€ posts was one I wrote way back in 2011 about my dislike for TODO style comments in code â€“ â€œTODO or TODO Not - There Is No Laterâ€. The premise of that post, which includes a number of examples from real codebases Iâ€™ve worked on, is that they are fundamentally pointless because they are almost certainly too low in value to get done. If they were valuable enough they either should be a proper feature on the backlog or be left to be handled as part of a relevant story, e.g. refactoring.
At the time I wrote that post I was convinced about them not living in the codebase (past the featureâ€™s release) but I suggested that any potentially useful ones should be converted into bona fide user stories so they could be formally considered and prioritised along with the other items. After receiving a reply to a tweet that referenced my aging blog post from a company that tries to quantify technical debt by analysing such TODO style comments I felt it must be time for an update. (The TL;DR of this post was my reply to them.)
// Learn to Let Go
One of the hardest lessons I have learned over the intervening 7 years is how to let go of stuff. What caused me to cling onto some of those TODOs that I would run across was a fear of forgetting something important. My daily use of a log book (see â€œPen & Paperâ€) to record notes as I go along exemplifies my apparent need to keep track of my current state as my brain is like the proverbial sieve. In an era where change was much harder because the software development QA process was largely manual this makes sense as it was more popular to batch-up changes. Couple this with a general disregard for anything non-functional, such as an appreciation for refactoring, and itâ€™s all too easy to see why people bury their personal backlog in the code rather than open it up for discussion with non-developers.
There is a familiar ring here and thatâ€™s because Iâ€™ve walked this path before more recently in 2016â€™s â€œDevelopers Can Be Their Own Worst Enemyâ€. With a modern development process that puts an emphasis on trust and transparency we can let go of the past and should have more confidence in our peers and the management to see the value in our opinions.
Itâ€™s also not acceptable to just leave a cryptic comment in the code about why something should be implemented differently or moved elsewhere â€“ the need to change must be backed up with a reason so that we can understand the value in it, and most TODO comments are throwaway rather than well reasoned arguments.
// Measuring Technical Debt
Iâ€™ll be honest, I genuinely cannot see the point of attempting to measure the level of technical debt in a codebase, even if it were possible to do so. For a start you need to decide if youâ€™re taking the original interpretation â€“ a conscious decision to temporarily take a shortcut - or the ever more popular one â€“ crap code. Even if you could do that, what are you ever going to do with the output? I once saw a SonarQube report that said we had Â£X million of technical debt in a codebase I was working on; how exactly does that inform you?
The reason I find it pointless is because it feels like itâ€™s measuring the wrong thing. Just like the story about the man looking for his keys under the streetlight we apply a tool to measure the quality of the code when what really matters is measuring our ability to deliver. The reason poor quality code affects us is because it makes future change hard and slows us down. Hence if it matters there must be a causal link because if the code is that bad our pace of delivery will slow down and weâ€™ll see that (all other things being equal).
But what is more important in my mind is that even if you did know how much debt you had you would only want to focus on the areas that are subject to change, and you do that already by focusing on the most valuable work in the backlog! And the technique for tackling the debt is refactoring. Hence we already have what we need to address the real problem.
// Trimming the Backlog
Unwinding the stack slightly let me return to the topic of reflecting unfinished work in the productâ€™s backlog.
That sentence should already be making your spider-senses tingle â€“ how can it be unfinished? If weâ€™ve not met the acceptance criteria weâ€™re not done, so carry on. If the acceptance criteria was wrong or incomplete then thatâ€™s a discussion to have with the product owner for clarification. Note that â€œof good qualityâ€ is an acceptance criteria inherent in every story we do as it is virtually non-negotiable .
Perhaps a better term would be undiscovered work. Woody Zuill has this saying â€œitâ€™s in the doing of the work that we discover the work that needs doingâ€. What we often unearth are things which never showed up in our initial analysis and therefore we now have to factor them into our schedule or decide to drop them. When weâ€™re knee deep in the feature it may seem really important to do it now, but given time the need may slowly dissolve, and in the end possibly disappear altogether.
What you might initially put on the backlog (or write as a TODO in the code) could be quite specific, e.g. â€œNeed to handle poisoned messagesâ€. As you continue you might also add other scenarios such as â€œShould refresh token before it expiresâ€ and â€œTriage malformed messages separately from those well-formed but still invalidâ€. These are all valuable behaviours which go towards building a reliable service but the initial focus might not be on reliability, maybe its currently just a tactical fix to enable learning about something else. You donâ€™t want to waste time over-engineering but at the same time you also donâ€™t want to forget what else you have learned doing it.
The problem with this mentality is that the backlog just grows and grows, and weâ€™re back to where we were before with TODOs littered all over the code â€“ itâ€™s just an every growing feature list. As time passes the need to implement some of those features will either happen because they have suddenly become important (itâ€™s no longer tactical) or they will vanish (it remains a mere stop-gap). Leaving the stories on the backlog just makes it harder and harder to prioritise as you keep going over old ground again and again.
Once again we need to let go and rely on the fact that if they are important they will eventually resurface. If you feel really uncomfortable about deleting them entirely then you might consider rolling up related stories back into epic sized ones as part of the backlog grooming. Applying this to our recent example you could easily fold them all into a single â€œService Reliabilityâ€ epic that would be easier to handle. You could turn each cardâ€™s title into a checklist item.
That said as I get older I become less tolerant of a never-ending backlog and want to be more aggressive in the backlog grooming. Part of that is down to having more confidence in knowing that issues will be addressed  in a more timely fashion and that prioritisation will take into account both the technical and functional features with more or less equal consideration because the team is trusted to do The Right Thing.
Being more experienced there is no doubt more than a grain of truth that my sphere of influence is probably wider but that shouldnâ€™t really matter. Every story must be valuable and ideally stand-up on its own merit, where my experience comes in is probably in being able to express that value more succinctly.
// TODO: Redux
I havenâ€™t seen, heard or read anything in the intervening years that has been able to convince me in the value of using TODO comments in the code as a more successful technique of managing what needs to be done. If anything my appetite for tracking any work outside the next few sprints / weeks has begun to wane simply because it is now so easy to change in direction with only a momentâ€™s notice should the situation deteriorate. This does not mean we should be reckless, far from it, but leaving a TODO in the code as a way of conveying a change in architecture hardly seems optimal either.
As for the notion that a TODO in the code can be equated with an increase in technical debt I donâ€™t buy that either. I would posit it is more likely to indicate a failure within the development process itself as the mismatch between behaviour and acceptance criteria either indicates a bug in the code or a bug in the requirements and neither of these outcomes sounds like something that should be brushed off lightly with a comment in the code.
 I try not to deal in absolutes as there always seems to be an exception, but either way it must be a conscious decision.
 Assuming the organisation is behaving in a moderately agile way and not just paying lip service to a couple of the ceremonies or practices.