Recently, I came across some horrible, horrible code. I immediately pasted it into a messaging application and quickly received an expression of solidarity. With what though? My indignation? Grief? Amusement? I find it suspicious that code I consider horrible tends to have been written by people I already disliked for some reason.
Here are some things I have complained about recently:
- Code that was the source of a bug that was in retrospect obvious.
- Code that could be deleted with no change to the behavior of the program other than, possibly, a performance improvement.
- Extremely inefficient code, perhaps extravagant in memory use or accidentally elevating the order of complexity.
- Extremely efficient code, in one tiny section of the program that made no measurable contribution to overall performance.
- Flow control making use of (a)
if/else, (b) monadic combinators, or (c) pattern matching, in lieu of one of the other two.
Occupying their own special corner of my lizard brain are the following nomenclatural iniquities:
- Ambiguous or (gasp) misspelled names. I got very upset recently about a block of code that contained three nearly identically named variables, differing only in the placement of underscores.
- Comical adherence to coding standards. Well, comical to me anyway. I found
val userUuid = UUID.randomUUIDhilarious.
- Symbols that were literally the opposite of the true meaning, for
example a list of excluded things called
- Symbols that had clearly been repurposed without being renamed, for
hostnamecontaining a user count.
Here are some things that I often do before complaining about horrible code:
- Googling to make sure that the complaint is legitimate.
- Learning from such googling that the complaint is not legitimate and then observing my blood pressure fluctuate in an interplay of rising embarrassment and receding indignation.
- Recalling such painful personal experiences to illustrate my sense of fairness and stiffen my resolve.
- Recalling that time when I woke up in a cold sweat the night after noisily pointing out someone's mistake that turned out either not to be a mistake or to be my mistake and deciding not to send my artfully composed email after all.
- But not deleting it from Drafts either.
- Realizing that, while I know that the code in question is horrible, I don't understand precisely why, and so spending the rest of the afternoon reading about catamorphisms.
- Realizing and then suppressing the thought that I wrote code that was horrible in a very similar way, actually quite recently.
With reference to that last point:
An ignorant person is one who doesn't know what you have just found out. - Will Rogers
- This code makes me nervous and raises my cortisol levels. I have OCD, for chrissake.
- But my genuine surprise is no less wounding than feigned surprise.
- This mess makes it hard to do my job and may lead to outages!
- Seriously, what is the objective importance of either my job or your outages?
- It's so funny!
Existential crises after pondering a world where no code could be called horrible anymore:
- Could code in such a world ever meaningfully be called good - or wonderful? Would code not so designated be by implication horrible.
- But craftsmanship is an objective good, no?
- Why? Isn't craftsmanship basically about making nice things for rich people to display ostentatiously? Doesn't all morality come down to aesthetic preference anyway?
- Something that I find important is evidently not important to everyone. This makes me moderately sad.
- If two people disagree about what is horrible, can anything they say to each other be called communication?
- Glimpses of a chaotic hell. Heat death of the universe.
Commentscomments powered by Disqus