Comments for Now You
There’s a programming joke about comments I heard a few years ago, kind of forgot, and can’t find now. It goes something like this:
Newbie Dev: Lol comments r dumb
Junior Dev: Comments explain what you did for other devs later
Mid-Level Dev: Comments explain why you did it for other devs later
Senior Dev: Comments explain why you did it for you later
I’ve always mentally added my own1:
Galaxy2 Dev: Comments explain what I’m doing right now
Not all that often, but sometimes, I’ll be banging my head against some intricate problem (it almost always seems to involve multiple JS Array.prototype.reduce
s for some reason), and eventually start to suspect that I’m mentally glossing over some aspect of the solution that isn’t making it into the code, or is poorly implemented, because I haven’t explicitly understood it to even be a problem. So I write a comment explaining to, ostensibly, a future me or future dev, but really to present me, explaining exactly what the program is intended to do. Then I write the implementation of the comment. This invariably gets me at least one step closer to the solution.