Halmurat T.
Halmurat T.

Senior SDET

Home Blog Books ask About

The Dispatch

Weekly QA notes from the trenches.

Welcome aboard!

You're on the list. Expect real-world QA insights — no fluff, no spam.

© 2026 Halmurat T.

Automation 24
  • Selenium
  • Playwright
  • Appium
  • Cypress
AI Testing 5
CI/CD 6
  • GitHub Actions
  • Slack Reporting
QA Strategy 4
Case Studies 5
Back to Bookshelf
§Book Summary

Clean Code

A Handbook of Agile Software Craftsmanship

by Robert C. Martin (Uncle Bob)

Buy on Amazon
§In One Sentence

"The only way to make the deadline — the only way to go fast — is to keep the code as clean as possible at all times."

What This Book Is About

The book opens with the cost of messy code: over time, productivity drops toward zero as the mess grows. Teams demand rewrites. The rewrite race "can go on for a very long time. I've seen it take 10 years." Martin places the blame on programmers, not managers: "it is unprofessional for programmers to bend to the will of managers who don't understand the risks of making messes."

The book collects definitions of "clean code" from six experts (Bjarne Stroustrup, Grady Booch, Dave Thomas, Michael Feathers, Ron Jeffries, Ward Cunningham), then spends 17 chapters teaching you how to write it. The guiding principle: "Leave the campground cleaner than you found it."

What Is Clean Code? (Six Definitions)

Bjarne Stroustrup (inventor of C++): "Clean code does one thing well." Elegant and efficient, with straightforward logic, minimal dependencies, complete error handling.

Grady Booch: "Clean code reads like well-written prose." Simple, direct, with crisp abstractions and straightforward lines of control.

Dave Thomas: Clean code "can be read, and enhanced by a developer other than its original author." It has unit and acceptance tests, meaningful names, minimal dependencies, and a clear API.

Michael Feathers: "Clean code always looks like it was written by someone who cares." There is nothing obvious you can do to make it better.

Ron Jeffries: Simple code (1) runs all the tests, (2) contains no duplication, (3) expresses all design ideas in the system, (4) minimizes entities.

Ward Cunningham: "You know you are working on clean code when each routine you read turns out to be pretty much what you expected."

The Rules (Chapters 2-9)

Meaningful Names (Ch 2)

Use intention-revealing names. "If a name requires a comment, then the name does not reveal its intent." int d; // elapsed time in days becomes int elapsedTimeInDays;

Use searchable names. "The length of a name should correspond to the size of its scope." Single-letter names only in tiny scopes. MAX_CLASSES_PER_STUDENT is searchable; 7 is not.

Class names = nouns. Method names = verbs. Classes: Customer, WikiPage, Account. Avoid Manager, Processor, Data. Methods: postPayment, deletePage, save.

Pick one word per concept. Don't use fetch, retrieve, and get for the same thing in different classes. "A consistent lexicon is a great boon."

Functions (Ch 3)

"The first rule of functions is that they should be small. The second rule is that they should be smaller than that." The book says functions "should hardly ever be 20 lines long." Indent level should not be greater than one or two.

"Functions should do one thing. They should do it well. They should do it only." If you can extract another function with a name that is not just a restatement of its implementation, it's doing more than one thing.

Zero arguments is best. "The ideal number of arguments for a function is zero. Next comes one, followed closely by two. Three arguments should be avoided where possible." Flag arguments (booleans) are "a truly terrible practice" — split into two functions.

Have no side effects. "Side effects are lies. Your function promises to do one thing, but it also does other hidden things." A checkPassword that also initializes the session creates a hidden temporal coupling.

Comments (Ch 4)

"The proper use of comments is to compensate for our failure to express ourself in code. Note that I used the word failure. I meant it."

The book says "inaccurate comments are far worse than no comments at all" and "truth can only be found in one place: the code." Good comments: legal headers, warnings of consequences, TODO notes, clarification of obscure code. Bad comments: redundant, misleading, mandated, commented-out code ("Few practices are as odious as commenting-out code. Don't do this!").

Error Handling (Ch 7)

Use exceptions, not return codes. Return codes "clutter the caller" and are easy to forget. Exceptions separate error handling from the happy path.

Don't return null. Don't pass null. "When we return null, we are essentially creating work for ourselves and foisting problems upon our callers." Use exceptions or special case objects instead.

Unit Tests (Ch 9)

The Three Laws of TDD: (1) Don't write production code until you have a failing test. (2) Don't write more of a test than is sufficient to fail. (3) Don't write more production code than is sufficient to pass the test.

"Test code is just as important as production code." The book tells a story of a team that let tests get dirty — they became so hard to maintain that the team discarded them. Without tests, defect rates rose and code began to rot. "Having dirty tests is equivalent to, if not worse than, having no tests."

F.I.R.S.T. — Fast, Independent, Repeatable, Self-Validating, Timely. "If you let the tests rot, then your code will rot too."

Kent Beck's Four Rules of Simple Design (Ch 12)

In order of importance:

1

Runs all the tests. "A system that is comprehensively tested and passes all of its tests all of the time is a testable system." Making systems testable pushes toward small, single-purpose classes and loose coupling.

2

Contains no duplication. "Duplication is the primary enemy of a well-designed system." It represents additional work, risk, and complexity.

3

Expresses the intent of the programmer. "The majority of the cost of a software project is in long-term maintenance." Choose good names, keep things small, use standard patterns, write expressive tests.

4

Minimizes the number of classes and methods. This is the lowest priority — "it's more important to have tests, eliminate duplication, and express yourself."

66 Code Smells and Heuristics (Ch 17)

The final chapter is a comprehensive reference: 66 named smells and heuristics organized into seven categories. Some highlights:

Comments (C1-C5)

Inappropriate info, obsolete, redundant, poorly written, and commented-out code ("an abomination — delete it!").

Functions (F1-F4)

Too many arguments, output arguments, flag arguments, dead functions.

General (G1-G36)

36 rules including: G5 Duplication ("one of the most important rules"), G20 "Function names should say what they do," G23 "Prefer polymorphism to if/else or switch/case," G29 "Avoid negative conditionals," G31 "Hidden temporal couplings."

Names (N1-N7)

Descriptive names, appropriate abstraction level, standard nomenclature, unambiguous, long names for long scopes, no encodings, names describing side effects.

Tests (T1-T9)

Insufficient tests, use coverage tools, don't skip trivial tests, test boundary conditions, "bugs tend to congregate" (test near bugs exhaustively), tests should be fast.

Environment (E1-E2)

"Build requires more than one step" and "tests require more than one step" — both should be one command.

The book concludes: "Clean code is not written by following a set of rules. You don't become a software craftsman by learning a list of heuristics. Professionalism and craftsmanship come from values that drive disciplines."

Quotes from the Book

"It is not enough for code to work. Code that works is often badly broken. Programmers who satisfy themselves with merely working code are behaving unprofessionally."

"Indeed, the ratio of time spent reading vs. writing is well over 10:1. We are constantly reading old code as part of the effort to write new code."

"It is unit tests that keep our code flexible, maintainable, and reusable. If you let the tests rot, then your code will rot too."

"Nothing has a more profound and long-term degrading effect upon a development project than bad code."

Who Should Read This

  • Every developer — This is one of those books that fundamentally changes how you look at code. The naming and functions chapters alone will make you a better programmer immediately.
  • SDETs and test automation engineers — Chapter 9 on unit tests and the F.I.R.S.T. principles apply directly to test code. The book says "test code is just as important as production code."
  • Code reviewers — The 66 smells in Chapter 17 give you a shared vocabulary for review feedback. Instead of "this feels messy," you can say "G5: duplication" or "F3: flag argument."
  • Tech leads setting coding standards — The book provides a comprehensive, well-argued set of standards your team can adopt or adapt.

§ Verdict

8 / 10

Chapters 1-9 are the strongest — meaningful names, small functions, comments, error handling, and unit tests are immediately actionable. Chapter 17 (66 smells) is a great reference to keep open during code reviews. The case study chapters (14-16) are instructive but very Java-specific and can feel dated. Some advice is intentionally extreme ("functions should hardly ever be 20 lines long") — treat it as a compass direction, not a GPS coordinate. The book uses Java throughout, but the principles (naming, small functions, no side effects, clean tests) apply to any language.

§ Colophon

Halmurat T. — Senior SDET writing about test automation, CI/CD, and QA strategy from 10+ years in the enterprise trenches.

Set in
IBM Plex Sans, Lora, and IBM Plex Mono.
Built with
Astro, MDX, Tailwind CSS & Expressive Code. Served by Vercel.
Privacy
No cookies. No tracking scripts on the main thread — analytics run sandboxed via Partytown.
Source
github.com/Halmurat-Uyghur
Terminal
Try /ask to query Halmurat's notes in a shell prompt.

© 2026 Halmurat T. · Written in plain text, shipped in plain time.

Search
Esc

Search is not available in dev mode.

Run npm run build then npm run preview:local to test search locally.