Anyone who’s worked on a sufficiently large code base will have probably come across a comment like this one.
// TODO: Refactor this
No doubt left there by some well-meaning developer and probably ignored by everybody else since.
Sometimes it will be accompanied by a rant about exactly what’s wrong with the code in question.
Comments like this serve no useful purpose!
They may serve as a bit of a stress-relief for the person inspired to write it but other than that are a waste of time. If the person leaving it wasn’t inclined to do the refactoring then what makes them think someone else will?
Or maybe they optimistically think they can come back when they get some free time and do it. They almost never will find that free time – the comment will sit there until the developers on the team no longer even notice it anymore.
Here’s what I like to do when I come across some code that I think could do with some refactoring…
Consider working on it right away
If I have time and/or it’s in scope I’ll try to refactor it there and then.
If I can’t do it right away…
Raise a tech debt ticket in the bug tracking software
This creates an actionable task that can be discussed by the team and tracked.
Leave a TODO comment referencing the bug tracker number
This ties the code in question back to the ticket.
Add my name/initials to the comment
This gives people someone to talk to if they happen across the comment.
Oh yeah, and I save the rants for down the pub!