Inversion: Become a good programmer by not being bad

Published on Tuesday, 12. October 2021

About twelve years ago, I wrote my first hello world program. Since then, I have learned a lot. I still think I'm at best a mediocre programmer. In some aspects, I'm downright awful. And there are always areas to improve. One trick I find useful to learn something new is inversion. Instead of trying to be a genius, I simply try to be consistently not bad. It doesn't matter how brilliant you are in your brightest moments if you delete the production database twice per week out of carelessness. Doing this is much more straight-forward. Simply think about what a bad programmer does and do the opposite.

A bad programmer doesn't know the tools he's working with.
Your tools include but are not limited to your editor, git, the programming language you're working in and (hopefully) the command line. If you put in a bit of effort into learning your tools you'll find all kinds of shortcuts or helpers that will make you more productive. Or you'll learn to avoid the traps and time killers in your project (I'm looking at you, undefined behaviour). If you don't, you might find a big chunk of your time spent on routine work that could be solved by a fancy one liner.

A bad programmer doesn't admit to his mistakes.
If you've written the core logic for the collision detection in a game and the collision detection doesn't work, it's likely that you made a mistake. So far, not a problem. Anyone will make a mistake sometime. Just get back to it, find the cause, and fix it. Sometimes, it will be something as simple as forgetting a return value. A bad programmer will be too sure of himself. He will defend is code vociferously, claiming that he checked everything and the error can't be possible come from him. And he will only give in, when his teammates have enough, debug the code for themselves and find the function with the missing return value. Don't be this guy. Working with him is a pain.

A bad programmer doesn't work to make his code understandable
I'm not just talking about documentation, even though that's a part of it. It's also about using clear variable names, function interfaces, and adding a comment explaining the obscure hack you introduced that somehow solved the problem. If you're writing code that only you understand, in a few months, nobody will understand it.

A bad programmer doesn't make mistakes
One way to learn something new is to read a book about the topic you're interested it. Please do that. Reading is valuable. The best way to learn, however, is to be out there and do things as much as possible. If you aren't confused or frustrated at least some of the time, you're doing something wrong. Working on things above your skill level means that you will make mistakes. This is great. It's proof that you're out there doing something. So make mistakes, lot's of them. And learn from them. And believe me, you will. If a stupid mistake just cost you a week of your time, you will remember it for the rest of your life. Or until dementia sets in. But that's another topic.

A bad programmer doesn't get the job done.
Yes, writing beautiful code is a reward in itself. Reading beautiful code can be as inspirational as reading a great poem. It's also irrelevant. The only thing that's important is that your program does what it's supposed to do. Nobody cares about how the sausage is made. And this is the most essential difference between a bad and an excellent programmer. An excellent programmer gets the job done. He understands what problem he needs to solve and knows the best way to solve it considering all circumstances. A bad programmer either doesn't understand the problem, or doesn't know the best way to solve it. Or he focuses on the wrong problem. I once wrote a custom JSON parser for a game I was working on. It was a fun thing to do and a week of wasted effort. Bad programmers might waste their time on irrelevant details. Or they might be not detail oriented enough. So, if you want to become better at programming, think about how you can eliminate the biggest time wasters you're having trouble with.