I recently watched Clean Code, where none other than Uncle Bob (Robert C. Martin) delves into the essence of clean code. For those unfamiliar with Uncle Bob, he’s a software development legend. His influence in the software world is massive, especially through his contributions to the Agile Manifesto and his many writings on software principles. Let’s take a quick look at how Wikipedia describes him:
Robert Cecil Martin, colloquially called “Uncle Bob”, is an American software engineer, instructor, and best-selling author. He is most recognized for developing many software design principles and for being a founder of the influential Agile Manifesto. Martin has authored many books and magazine articles.
However, this post isn’t just about Uncle Bob; it’s about what clean code truly means. In the video, Uncle Bob posed the question “What is clean code?” to several prominent figures in the software world. Their responses provide a rich perspective on what clean code represents to experienced developers.
What the Experts Say
Bjarne Stroustrup, the inventor of C++, answered:
“I like my code to be elegant and efficient. Clean code should do one thing.”
This is a simple but powerful definition. Clean code should strive to be both elegant and efficient—two qualities often seen as opposing forces. Elegance in code means achieving more with fewer words, while efficiency means using minimal system resources (CPU cycles). Stroustrup’s answer emphasizes the balance between these two qualities. Code should be focused, doing exactly what is required without unnecessary complexity.
Grady Booch, the author of Object-Oriented Design and Analysis with Applications, a classic text in software design, contributed:
“Clean code is simple and direct. Clean code reads like well-written prose.”
For Booch, clean code has an almost literary quality. It should read as easily as a well-written book—clear, concise, and without unnecessary ornamentation. It’s not about showing off cleverness but rather about making sure the code communicates its intent in the most straightforward way possible.
Michael Feathers, author of Working Effectively with Legacy Code, offered a more emotional take:
“Clean code always looks like it was written by someone who cares.”
Feathers reminds us that clean code reflects the mindset of the developer. It’s written with care and attention, conveying a sense of craftsmanship. When we approach our work with pride and thoughtfulness, it shows in the results.
Ward Cunningham, the inventor of the wiki, added:
“You know you are reading clean code when every routine that you read is pretty much what you expected.”
Cunningham’s response underscores the predictability of clean code. When you read it, it behaves and flows as anticipated. There’s no confusion, no surprises—just clarity. Clean code is intuitive because it aligns with what a fellow developer might expect when reading it.
The Common Thread
From these perspectives, we can draw some key principles that define clean code:
- Elegance and Efficiency: Do more with less.
- Simplicity and Clarity: Make it read like prose, simple and direct.
- Care and Craftsmanship: Write with thoughtfulness and intention.
- Predictability: It should behave as expected, with no surprises.
At its core, clean code is easy to understand. That’s the goal—writing code that communicates effectively with other developers.
Uncle Bob’s Golden Rule
As Uncle Bob succinctly put it:
“Remember that it doesn’t require an awful lot of skill to write a program that a computer understands. The skill is in writing programs that humans understand.”
This quote encapsulates the true challenge in software development. Computers are binary machines—they will execute even the most poorly written code as long as it compiles. But clean code ensures that other people can understand, maintain, and build upon your work. After all, we don’t write code in isolation; we write for future developers, collaborators, and even our future selves.
A Thought to Live By
One quote from the video that resonated with me is one I try to live by in my daily work. It comes from Robert Baden-Powell, the founder of the Boy Scouts. In his posthumous message to the organization, he said:
“Leave the world better than you found it.”
What if we took that philosophy to heart in our coding practices? What if every time you checked in code, you made it just a little bit better than it was when you checked it out? Small, consistent improvements over time can transform even the most tangled codebases into something clean, elegant, and efficient.
This is what I strive for in my daily tasks: to leave my code a little better than I found it, continuously improving the overall quality of the project.
Happy coding!
Photo by Oskar Yildiz on Unsplash