I'm a Terrible Programmer, And You Should Be Too
(by Erik Peterson on January 13th 2008)

This being the first post on this illustrious blog, I figure I'd explain that subheading you see right up there. Let me lay it on you, short and sweet:

I am a terrible programmer.

Seriously. I'm not very good. About half the lines of code that I write are broken. The way I do things the first time is almost always the wrong way. It is rare that I look at a piece of code that I've written more than a month ago without saying "Damn. That is some gross-looking code." And you know what? Somehow, I manage to ship rock-solid, scalable and nearly bug-free systems. And you can too! All you have to do is embrace the terrible programmer that resides within each and every one of you.

The key to milking quality code out of a terrible programmer is that you first, before all else, have to admit you are a terrible programmer. Only through that admission and the terrible fear of being discovered can you, a terrible programmer, create some fantastic systems. The idea is that by simply knowing this, you've already taken the first step on the long path to not being a terrible programmer. It's kind of like the twelve steps of crappy code addiction, where you first have to admit that you have a problem.

This philosophy is kind of an offshoot of what I like to call the Dunning Effect. This is the idea that dumb people tend to overestimate their intelligence or ability, and smart people tend to underestimate it. Therefore, if I am smart enough to realize that I am dumb, I am actually smart. Applied to programming, If I am a good enough programmer to realize that I am a terrible programmer, I am actually a good programmer. But this isn't all hocus-pocus "believing will make it happen" bullshit. This isn't The Secret®. This is serious stuff we're talking about here. Without further ado, let me introduce:

Erik's Terrible Guide to Not Being a Terrible Programmer By Realizing You're Terrible

Part 1: Paranoia
The first step toward exploiting your mediocrity in order to achieve greatness is to be really, incredibly paranoid about it. What if my wife finds out that I'm a terrible programmer? She'll divorce me. I can't let that happen! I must test my code! I must refactor obsessively! I must fix bugs before they're found!

The most important part of this is to test your code, and I don't mean "run through it once before you commit." I mean create some killer unit tests (and functional and integration tests, if your framework is in to that sort of thing). I'm so afraid that my coworkers will find out that I'm an awful programmer that I always run greater than a 1:1 code to test ratio. For stuff that would surely out me if it were to break (accounting software, life-saving medical devices, etc), I usually run at about 1:2. Believe me, these tests get run quite often. Beyond that, I always, always use multistage deployment. This means that I stand up a staging environment that is mirror image of the production setting, and I go to town. I do shit that would shame a two-year-old. I try to break stuff so hard you'd think I was Rick Allen doing a drive-by high five. If anything breaks, I fix it and write a test that duplicates the bug to make sure it never comes back. Why? Because I'm so terrible, I'd probably let it happen again!

It goes beyond just testing though, buddyboy. I'm such an awful programmer, I don't even have confidence that my exhaustive automated testing practices will prevent a bug from ever reaching a user. I make sure that I know about any errors the same instant that my users do. That way, by the time Frank shoots me an email saying "Man, Erik, this shit is broken. You're such a terrible programmer!" The bug will already have been fixed and deployed, and I can tell Frank that he must be seeing things, because it works fine now. He'll never suspect that underneath these clothes, I'm actually wearing Terrible Programmer underwear. It'll just be my dirty little secret.

Part 2: Grand Theft Code

The second part of Being a Great Programmer by Being a Terrible Programmer™ is realizing that pretty much anyone else out there who has ever written any code is a better programmer than you. That means you must copy code like mad. Lucky for you, people freaking love sharing code. They call this shared code "Libraries", "Frameworks", or maybe even "Plugins". If you're doing anything, you have to first realize that somebody's probably already done it, and that it's probably been done better. You just have to find out if they've published it, find it and then mercilessly rape and pillage that code until they're crying themselves to sleep at night.

By using other people's code wherever possible, you can rest assured knowing that you've completely minimized your chances of fucking up. And rest well you will, my friend. Like your dog who sleeps so soundly because he spent 36 minutes chasing his own tail, you will sleep like a baby due to your overwhelming incompetence.

Well, that's it for today. I hope you've learned that you are an awful programmer, and it is the most important thing you know.