William Bartlett
Sep 9, 2018 · 2 min read

Here are the suggestions I give the most.

Suggestion 1: Learn about booleans

Seriously, newbies, learn about the boolean type, and start using booleans properly in if and while statements.

The code below is just plain stupid. If you have a habit of writing it, don’t worry. You are just like countless other new people to the profession. But if you want to remain a programmer, grow up, and refrain from making mistakes with booleans.

Suggestion 2: Avoid Primitive Obsession and Data Clumps

This is more general than your Suggestion 2, and actually refers to existing code smells (https://refactoring.guru/smells/primitive-obsession, https://refactoring.guru/smells/data-clumps).

I have seen a variation of Primitive Obsession which could be called Map Obsession where instead of writing classes with fields, the developer used maps with string keys where each key was a field name!

Suggestion 3: Write a stupid implementation first, then refactor it

This is a subset of the Red-Green-Refactor. I give it as a first step towards mastering full-on TDD.

All too often programmers clump everything into one uber-method that works and then consider their work done. Please do the next part which is at least to make the code more readable. Code must communicate what is happening as well as how. But your work still isn’t done after these two steps. There are two more: https://youtu.be/l1Efy4RB_kw?t=847.

Other programmers optimize prematurely, thinking they know better than the compiler. Seriously, if you have never written a compiler, you have absolutely no idea what the machine code will be. There are phases in the compiler, and maybe even the runtime, that could optimize your code beyond recognition. All this optimization comes at a price, which is the sum of the extra time it took the author to write it plus the time it takes for every subsequent developer to understand the code, and make changes. The optimization could end up being a complete loss because that part might never become a bottleneck.

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade