10 commandments of programming

darlanalves

Darlan Alves

Posted on January 7, 2021

10 commandments of programming

These are 10 rules that I follow and will help you with being a better professional and effective developer.

1. If it’s hard, it’s wrong.

If a problem seems too hard to tackle, either you don’t know exactly what you are doing or you are doing it wrong.

Break down your problem into smaller pieces and try to decouple everything. Write pseudocode or create a PoC. Use pen an paper and talk about your solution with a colleague. These are great ways to check if you’re going in the right direction.

2. Don’t reinvent the wheel.

We love coding. Of course we do. But writing your own solution to everything just because we want it to be exactly like “this” or “that” is a waste of time and money.

But you should reinvent things from time to time, just for fun.

You will understand how things work to the tiniest detail. And you can only innovate or improve on things that you know very well.

3. Never stop learning.

Programming is hard. Thinking about all possible ways that something can go wrong is exhausting. Dealing with edge cases and crazy users is an insanity. But you will have to spend some time out of that madness to keep learning new things.

Try a new framework, write pet projects, fill your Github account will endless crap that no one will ever see.

That’s gonna be great for your one day, when you face a problem and “Aha, hold on!”, you know how to fix it because you tried that before.

4. Always be clear about what you are doing.

Don’t start coding until you know exactly what needs to be done.

There’s nothing worse than someone writing code at random and just hoping it will work at some point.

That only adds up to a pile of unmaintainable mess.

5. Don’t repeat yourself.

Reuse everything you can and keep things coherent. But don’t go too crazy either.

The whole point here is… if you need to change something, you should have to change it only in one place. Otherwise, you will make mistakes.

6. Write tests for everything.

Not a single line of code should go to production without some form of testing. And don’t trust your coverage either!

Code Coverage is a lie you tell yourself. It's just code porn.

Make sure you write a test, then write a line of code to pass that test.

Only this way you will know for sure that every single thing in your system is tested.

7. Don’t comment, unless you really, really need it.

Unless something incredibly hard to understand is part of your job, no comments should be tolerated.

Long if condition? Write the condition to a local constant that explains what’s that.
Weird algorithm? Write a function with a name that explains what it does.

Comments rot, and rot very fast.

8. The best code is no code at all.

Code is hard to maintain, so whenever possible, don’t write it.

Think how you can make it both more elegant and less verbose, and over time, it will shrink and work better.

9. Always leave the code you changed cleaner than you found it.

Follow the Boy's Scout rule of programming.

10. Stick to the rules!

Discipline will pay off in quality and clarity over time.

Things should be black and white. If you establish a rule, follow it to the letter.

Why? Because you don’t have to think about it!

Your precious brain juice is better spent on things that you DO have to think about.


Which rules do you follow?

Create a post or share in the comments which rules you follow every day!


Also recommended: Watch this series of Clean Code talks from Uncle Bob:

https://www.youtube.com/watch?v=7EmboKQH8lM
https://www.youtube.com/watch?v=2a_ytyt9sf8
https://www.youtube.com/watch?v=Qjywrq2gM8o
https://www.youtube.com/watch?v=58jGpV2Cg50
https://www.youtube.com/watch?v=sn0aFEMVTpA

💖 💪 🙅 🚩
darlanalves
Darlan Alves

Posted on January 7, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related