Skip to content

Good Code

10 PRINT "HOME" 20 PRINT "SWEET" 30 PRINT "HOME" 40 GOTO 10

I do not know what good code looks like.

I would not recognize it if I saw it.

I know this because I do know what bad code looks like. I see bad code every day. Most of the bad code I see every day is my own. I know what bad code looks like because I see it whenever I fix a bug. I see it whenever I refactor code to be shorter, more concise, and more readable.

I am fortunate when the code I'm debugging was written in a clean manner. I am fortunate when the code I'm debugging is well formatted. These qualities make my job easier, but they do not make good code.

Good code is code that does what it's supposed to. Good code is code that behaves. Good code is code that works for years without modification or error.

My job is to fix bugs in bad code: code that misbehaves, code that has errors, code that needs to change. By definition, none of the code I read on a daily basis is good code. The code I recognize and am familiar with is all bad code.

I write lots of bad code.

Once in a while, I'll take a break from the debugging. I take a break from the fixing and updating and writing. I take a break from bad code. During these breaks, I open old code files. Sidebar modules that show some text, or service code to grab some data. I try to find code that hasn't changed in over a year. I try to find code that no one is complaining about. I try to find good code.

After some digging I usually stumble on some, hidden in a project that's been live for some time, or a few utilities to make some tedious task easier. I can only recognize it because of its age. I need to look at commit history to even begin to know where to look. It's always surprising to see it. It doesn't stand out as special. It usually doesn't quite fit any pattern. It's usually a little bit rough with parts that "could be improved" whether by refactoring, reformatting, or rewriting.

It's after reading this "good code" that I always need to remind myself:

I do not know what good code looks like.

I would not recognize it if I saw it.