15 Minutes
Cover of Clean Code: A Handbook of Agile Software Craftsmanship

Technology and the Future · 15 min

Clean Code: A Handbook of Agile Software Craftsmanship

Robert C. Martin · 2008

Who it's for

This is for you if you write code, are just starting out in the field, or inherited a system nobody has the nerve to touch. Clean Code is a craft manual on how to write programs that other people, and you yourself six months from now, can read and change without suffering.

Read it in the app

⚡ Free to download • 🎁 One full book free every day

3 ideas to take with you

1

Messy code charges interest: every shortcut you take today becomes an hour lost by whoever has to touch it tomorrow.

2

Whoever writes code is writing for people, and the machine is just the easiest reader to please.

3

A system is only cheap to maintain if the team has the nerve to change it, and that nerve comes from tests that work.

“
Code that only you understand is a favor you do for today's you and bill to tomorrow's you.
An idea from Clean Code: A Handbook of Agile Software Craftsmanship, in the words of 15 Minutes

Preview

Start reading now

Why dirty code costs so much

The book opens with a complaint every programmer recognizes: systems that start out fast and later grind to a halt. A shortcut here, a quick hack there, and suddenly every simple change takes days, because nobody understands what already exists. Martin treats this as the main hidden cost of software development.

Picture the online store of a small company in Columbus. In the first year, the owner asks for a new promotion every week and the programmer ships it the same day. By the third year, the same promotion takes a month, because touching one spot breaks two others. The code didn't change languages, it just rotted.

The author's thesis is that mess is not a necessary evil of tight deadlines. According to him, writing dirty code is slower even in the short run, because you will trip over what you just did. Cleaning up is not a perfectionist's luxury, it is part of the job.

What the book calls clean code

Martin does not give a single definition. He gathers opinions from experienced programmers, and what repeats is a set of ideas: clean code is simple, direct, free of duplication, and looks like someone cared. Whoever reads it understands the intent without needing a map or a translator.

Think of a well-written text, like a good newspaper article. You glance at the headline, understand the subject, and move on to the details only if you want to. Clean code works that way: names and structures tell the story, and the reader goes deeper as needed.

There is also the Boy Scout Rule, which runs through the whole book: leave the place a little cleaner than you found it. You don't have to overhaul everything at once. Each time you open a file, you improve a name, break up a big function, or delete a dead chunk, and the system gets better bit by bit.

Names that tell the truth

The first practical advice is about names, and it seems small, but the author insists that names are half of reading. A variable called d or list1 forces the reader to look elsewhere for its meaning. A name like daysSinceLastPurchase answers on its own, and it is worth the effort of typing more letters.

The book asks for names that reveal intent, avoid misinformation, and can be searched for. Calling something a list when it isn't a list is confusing. Single letters are acceptable only in tiny loops. And names that are too similar, differing by one detail, are an invitation to mistakes.

There is also care about keeping a consistent vocabulary. If in your system you look up customers with the word fetch in one place and get in another, the reader will wonder whether they are different things. Choosing one term per concept removes a lot of doubt.

11 more sections and the quiz

Continue in the app

Read the whole summary, finish with the Clean Code: A Handbook of Agile Software Craftsmanship quiz and follow the guided Journeys. No ads in the app.

About Robert C. Martin

Robert Martin, known as Uncle Bob, is an American software engineer and consultant with decades of experience in object-oriented programming. He was one of the signatories of the Agile Manifesto in 2001. He has written other books on the craft, such as Clean Architecture and The Clean Coder. Clean Code was published in the United States in 2008.

Explore