Rating:
5/5
Read: 2020-05-10
Review
Clean Code is arguably the most influential book for software developers. "Uncle Bob" Martin presents a school of thought that prioritizes readability and maintainability above cleverness. While some examples (Java) feel dated, the principles are timeless.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
Key Takeaways
- Meaningful Names: Variables should answer why they exist, what they do, and how they are used.
int d; // elapsed time in daysis bad.int daysSinceModificationis good. - Functions: Should do one thing, do it well, and do it only. If a function contains sections (e.g., declarations, initializations, logic), it's probably doing too much.
- Comments: The goal is to express yourself in code. Comments are often a failure to make the code clear enough. "Don't comment bad code—rewrite it."
- Formatting: Code is communication. Vertical openness between concepts and vertical density within concepts affect readability heavily.
- Error Handling: Create clean boundaries between application logic and error handling. Prefer exceptions to return codes.
Personal Impact
Reading this book early in my career changed my mindset from "getting it to work" to "crafting it to last." I apply the Boy Scout Rule (Leave the campground cleaner than you found it) to every pull request I submit.