~/blog/clean-code-by-robert-c-martin.mdx
blog8 min#books#career

clean code by robert c. martin

Feb 20, 2024

clean code is a classic.

I am not the first to summarize; I won’t be the last! Thank you to my partner for gifting this book to me when I started my career change. 🙏 After I read Clean Code: A Handbook of Agile Software Craftsmanship, it was requested I share insights with my team. Any chance to share knowledge is a win! I share the details included in my presentation here, focusing on the most widely applicable content.

Quick notes:

Here, we’ll cover:

🎬 the presentation

The conversation that was sparked pleasantly surprised me when I presented to the team in the Western hemisphere. Some insights:

Here is a link to the slides! And here’s a recording of the presentation (~15 minutes):

💡 my 3 big takeaways

  1. Writing code is a process. Start with a draft, refine, and repeat. It takes practice.
  2. What ultimately matters is that your team agrees on standards and sticks to them.
  3. It is everyone’s responsibility to keep a codebase clean!

💻 what is clean code?

For me, clean code is beautiful and embodies discipline. It is concise and clear to any reader. Business needs and team members will inevitably change! So, it’s important to hone the craft to solve a problem with meaningful code for others to understand.

I especially like the application of the referenced “broken windows” metaphor:

“A building with broken windows looks like nobody cares about it. So, other people stop caring. They allow more windows to become broken. Eventually, they actively break them. They despoil the facade with graffiti and allow garbage to collect. One broken window starts the process toward decay.”

Dave Thomas & Andy Hunt

Several other interpretations of “clean code“ were provided by others in the industry. Here are some of the meaningful interpretations I extracted:

Without developer discipline, building new features slows over time. As the mess grows, so does the time needed for the codebase, especially for new team members! They must wade through it to make an impact.

Clean code sometimes requires pushback on timelines (within reason) for higher-quality output. Other team members (i.e., managers or product) rely on our honest estimations. Sure, we could get it working as a bare minimum, but we also need time to care for the code, keeping the product/service smooth and efficient. This should be acknowledged and considered. Why? Because even when we say we’ll return to it, historically, we won’t.

Tidiness takes a team effort to clean up - and maintain - the codebase. Martin recommends the Boy Scout rule when working: “Leave the campground better than you found it.” Care about your craft!

A smiling Earth illustration reading ‘Leave it better than you found it.’

🏗️ foundations: names, functions, comments, and formatting

What does this actually consist of? Let’s cover major areas where pain points arise.

names

What’s in a name anyway? Well, a lot of meaning, actually!

variable naming tips:

USE

AVOID

class naming tips:

USE

AVOID

functions

Functions are the heart of any program. They should have consistent blocks and indentation for an easily followed nested structure.

“The first rule of functions is that they should be small. The second rule of functions is that they should be smaller than that.”

comments

Everyone has their own view on this. Regardless, note point 2 in my main takeaways. If your team agrees on a pattern, adopt the pattern. Ultimately, the best advice I’ve received is that a comment should explain why you made a decision (like business needs) and not what your code is doing.

formatting

Why is this a foundation? It’s too important to ignore, and so many linting tools exist. There’s no excuse. Because there are many tools, I won’t go into excessive detail!

Again, it doesn’t matter what you do for formatting as long as everyone agrees and follows it on the team!

We’ve covered the foundational concepts! But, as Martin says, just because we might be able to recognize “dirty” code or “code smells,” we must also put it into practice!

“So too being able to recognize clean code from dirty code does not mean that we know how to write clean code!”

Chapter 1, “The Art of Clean Code?”

🚀 put it into practice

To put some of the following chapters into practice, I’ve pulled some of the more interesting or applicable concepts and suggestions!

“Of course bad code can be cleaned up. But it’s very expensive. As code rots, the modules insinuate themselves into each other, creating lots of hidden and tangled dependencies.”

🥸 code smells

Below is a table of common issues provided by Martin (excluding Java-related items).

You may need to scroll to see all the goodies!

Comments Environment Functions Names Tests General 1 General 2 General 3
inappropriate information build requires more than one step too many arguments choose descriptive names insufficient tests multiple languages in one source file artificial coupling be precise
obsolete comment tests require more than one step output arguments choose names at the appropriate level of abstraction use a coverage tool! obvious behavior is unimplemented feature envy replace magic numbers with named constants
redundant comment flag arguments use standard nomenclature where possible don’t skip trivial tests incorrect behavior at the boundaries selector arguments (bool) structure over convention
poorly written comment dead function unambiguous names an ignored test is a question about ambiguity overridden safeties obscured intent encapsulate conditionals
commented-out code use long names for long scopes test boundary conditions duplication misplaced responsibility avoid negative conditionals
avoid encodings exhaustively test near bugs code at wrong level of abstraction inappropriate static (referring to a method, prefer non-static methods) functions should do one thing
names should describe side-effects patterns of failure are revealing base classes depending on their derivatives use explanatory variables hidden temporal couplings (don’t hide it when it’s necessary)
test coverage patterns can be revealing too much information - hide info, keep it tight and small function names should say what they do don’t be arbitrary
tests should be fast dead code understand the algorithm encapsulate boundary conditions
vertical separation make logical dependencies physical functions should descend only one level of abstraction
inconsistency prefer polymorphism to if/else or switch/case keep configurable data at high levels
clutter follow standard conventions avoid transitive navigation

That’s a wrap!

🤔 questions to consider:

  1. Have you read Clean Code? Did you have any different insights or any I missed?
  2. What was your favorite or least favorite part?
  3. Do you agree/disagree with anything “Uncle” Bob Martin shared that I have listed?
  4. Have you - or are you - putting anything into practice in your daily work?
  5. Is this most relevant to new engineers, or is it also useful for seniors or managers?

🫶 bonus recommendation

I recently began listening to the Working Code Podcast (from the 2020 start…it’s how I listen to all podcasts). The hosts reviewed Clean Code in episodes #22 and #23.

Thus far, I highly recommend the podcast! The real banter is great for anyone who works remotely to feel like they can enjoy technical conversations anytime!

thanks so much for reading! ✨
🧡support the work

All of this (the podcast, the posts, the projects) happens on nights and weekends. If something here saved you a headache, the tip jar is always open.

ko-fi.com/mindiweik →
// related posts
Oct 8, 2024the software engineer's guidebook reviewJul 9, 2026the job search, honestlyJan 27, 2026building a compassApr 15, 2025the hidden currency of connection

// comments

Loading comments…

    leave a comment

    // subscribe

    New posts and episodes by email. No spam, unsubscribe anytime.