Following programming ‘best practices’ will slow you down

Who hasn’t stolen a cookie from the jar when Mom wasn’t looking?

Or stayed out with friends long after bedtime?

Or — God forbid — taken the shortcut through the park where shady people lurk, instead of going the long way over the main road?

Or, yes oh yes, which programmer hasn’t violated one of those etched-in-stone best practices, you know, one of the ones that you should follow at all costs?

It’s safe to say that many, if not most, of us have done this before. But maybe your rule-breaking is exactly why your code was better than average. At least it didn’t make you lose your job. Or make your computer explode at runtime.

Sure, breaking rules is never without risk. If you’re a brain surgeon, you really should follow the rule of “never cut this piece off.” (Forgive me for my bluntness, I’m no medical expert.)

But if you’re building software, what’s the worst case? Sure, if you’re designing killer drones or software for electric grids or support systems for spaceships you might want to go slow and follow the rules.

But those programmers who don’t have high stakes like that — and that’s most of us — you might want to question your rulebook from time to time.

Copy-pasting code isn’t the root of all evil

The die-hard open-sourcers and the die-hard purists may argue otherwise. But, in all earnesty, who hasn’t copy-pasted code snippets from StackOverflow and other places of the big wide internet?

First of all, if you have a problem that takes five seconds to google, you wouldn’t go annoy your coworker for ten minutes to make them fix it. And if the answer is on Stack, then, well, the answer is there.

The purists would argue that you shouldn’t copy anything because you might not understand what’s going on in the copied code. And they have a point.

But if you’re googling around anyway, you’re quite likely going to check the manual pages of the function that you’re copying over anyway. Plus, you’re probably going to need to adjust a few variable names and understand where to put that snippet of code. That’s not possible without a minimum of understanding.

Another point for the purists is that your ready-to-copy-paste code may contain non-printable characters. These are characters like a backspace or a horizontal tab that you can’t see on your screen, but that can have an effect on the output anyway.

Purists would therefore argue that if you’re going to copy code, at least type it yourself so you don’t accidentally copy non-printable characters and make a mess of your project.

That’s cool advice, but personally I don’t know anyone who has ever bumped into a non-printable character and messed up their code. I do know someone, though, who introduces typos everywhere: me.