Write Code for Humans, Not Computers

When you’re writing code, you’re writing it primarily for other people and only secondarily for the computer. For any given problem, there’s generally a myriad of solutions that produce the desired output, with varying degrees of computational efficiency, but, with few exceptions, the optimal choice is the one that’s clean, clear, and easy for human beings to reason about.

Avoid abbreviations
Use meaningful, descriptive names
Stay away from unconventional syntax
Ensure functions perform only one task
Avoid unnecessary complexity
Embrace whitespace
Refrain from duplicating code
Be consistent throughout your project

You should also aim for your work to be self-explanatory. If you find yourself sprinkling comments throughout each function, you’re almost certainly doing something wrong.

If you’d like to learn more about writing clean code, I recommend “Clean Code: A Handbook of Agile Software Craftsmanship” by Robert C. Martin.

Leave a Reply

Your email address will not be published. Required fields are marked *

© Michael Kovich | All Rights Reserved