RudolphLiu
Back to bookshelf

Robert C. MartinClean Code: A Handbook of Agile Software Craftsmanship

Clean Code: A Handbook of Agile Software Craftsmanship

by Robert C. Martin

Read: July 10, 2024⭐⭐⭐⭐⭐programming

A guide to writing clean, maintainable, and efficient code

Overview

Uncle Bob's classic on software craftsmanship. This book fundamentally changed how I think about writing code.

Core Principles

Meaningful Names

// Bad
const d = new Date();
 
// Good
const currentDate = new Date();

Names should reveal intent, avoid disinformation, and be pronounceable.

Functions

  • Should be small (really small!)
  • Do one thing
  • One level of abstraction
  • Descriptive names

Comments

"Don't comment bad code—rewrite it."

Good code should be self-documenting. Comments often become lies as code changes.

Key Takeaways

  1. Leave code cleaner than you found it - The Boy Scout Rule
  2. Code is read far more than it's written - Optimize for readability
  3. Professionalism - Writing clean code is a matter of professional pride

My Application

Since reading this, I've become much more intentional about:

  • Function naming and size
  • Reducing duplication
  • Writing tests first (TDD)
  • Refactoring continuously

Rating: 5/5

Essential reading for any programmer. While some examples feel dated (Java-centric), the principles are timeless.