The idea of clean code gained popularity with the publication of Robert Cecil Martin’s “Clean Code: A Handbook of Agile Software Craftsmanship” in 2008. However, the principles of clean code date back to the beginning of software development, and Martin’s book is an essential manual for people who aim for cleanly written code. It’s a programming classic, and if you’re serious about coding, you should read this book cover to cover! By Ritesh Shah.
The article main points are:
- Why write clean code?
- 7 “Clean Code” principles
- Follow the KISS, DRY, and YAGNI rules
- Naming conventions: Use intention-revealing names
- Functions with the same level of abstraction
- Readability over conciseness
- Don’t include (too many) comments
- Consistency throughout the code
- Don’t obscure logic with error handling
- Elegant code or workable code?
Clean coding is not a skill you can master overnight. Instead, it’s a set of principles that you need to incorporate into your coding life — and apply them whenever you write or fix code. Programming is both a craft and a science, and you can only learn to write better code with time and perseverance. We liked this one: Comments should, in fact, explain “why” you did something instead of “what” is happening in the code. Excellent!
[Read More]