this post was submitted on 20 May 2026
1040 points (99.9% liked)
Programmer Humor
31505 readers
1712 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Sometimes one does something in a certain way (which would otherwise be a shit way to do it) for very good reasons which are external to the code, be they requirements related, external upstream or downstream systems or due to existing system limitations or deployment environment.
More than a decade ago, I learned that even if one isn't at all prone to put comments in the code, you should add comments for such reasons in that quirky code: months or years later that will yield exactly the reaction of this meme when you or somebody else sees that code (whilst you might remember why you did, somebody else will certainly not)
Maybe even more importantly, it allows other people to actually remove that crap if the reasons behind it don't apply anymore, which they would otherwise not do because they would be fearful that the hacked-together pile of crap was needed for some reason elsewhere they were not aware of so they could not risk refactor it - most long lived codebases out there are riddled with crap which had pretty good reasons to be there back when it was done but it doesn't anymore, but which newer people can't just remove until they've gained a full understanding of the whole code base and how it's wired to the rest (and, even then, there's a risk that the reason is a requirement and if they just remove that code it breaks something that the users expect).
Even if you're the kind of coder that thinks that "the code is self explanatory" (something which, by the way, betrays a lack of experience in the full life-cycle of software that has been in production for years and been worked on by several people) do your future self and others a favor by explaining the choices derived from external reasons ("Why has the auto engineer chosen to put the steering wheel in a British car on the right side?") that led to code design which is NOT explainable by purely internal or good design or coding reasons.
(Or at least make it stupidly clear in the appropriate level of tests, which normally is requirements testing or integration testing)
If you're really good and working in a proper professional environment (most programmer aren't), consider tracing things back to the entries in the software requirements document, use cases or even elements of an use case, at least for the "quirky" choices.
Definitely. I've seen this advice summarized as "Comment 'why', not 'how'" and it's always helpful to come back to weird code and immediately understand these things.
Yeah, that wall of text is my rationale for doing exactly that.