Keep it CLEAN

I like dirty martinis and R-rated movies but my code is one place I always want to keep CLEAN.

CLEAN is an acronym I use to remind myself of the five key code qualities that I’ve found to have the biggest impact for improving the maintainability and extendibility of code.

Before I describe exactly what they are I just want to say that this is certainly not an exhaustive list, and it may not include all the qualities you look for in code.

But these are the ones I’ve found to be the easiest for me to call out and talk about with other people. They’re also the ones I’ve found to have the highest value.

For me, software quality is all about dropping the cost of ownership.

Quality in manufactured goods helps extend the longevity of the product. Higher quality products last longer. The same is true with software. Higher quality software should be able to last longer because it’s more fit for its purpose and it’s built to be extendible. So when the customer inevitably comes back with requests for improvements, the development team can implement those requests and make the customer happy. It may be a simple definition of quality but it’s a useful one.

And these qualities are quantitative. We can measure them in code. This makes them useful for helping us arrive at a consensus for what principles and practices to follow. They give us a rubric for evaluating basically everything we do in terms of writing code and building features.

And these qualities aren’t just present in code, we see them everywhere in the world around us—in the way we communicate, in our literature, and in the media we consume. They’re everywhere because they reflect how we like to process and understand the world.

I’ll cast these code qualities in terms of object-oriented programs because that’s what I’m most familiar with but these qualities are also present in languages from assembly to COBOL. Regardless of the programming language, we have the ability to create independent units of execution either as objects or as processes, and the more sophisticated the language the more capable we are at being able to create well-defined entities.

CLEAN relates to the consistency and relationship between entities. These should have well-defined characteristics, that is they should be focused in terms of their composition and in terms of their relationships. They should hide implementation details. They should treat each other autonomously and be defined in only one place.

We have names for each of these things and here they are:

  • Cohesive.
  • Loosely coupled.
  • Encapsulated.
  • Assertive.
  • Non-redundant.

The first letter of each of these words spells the word CLEAN. This is my acronym for code quality. I want my code to be CLEAN.

CLEAN code is also a shout-out to Uncle Bob Martin’s book Clean Code: a Handbook of Agile Software Craftsmanship and to Misko Hevery’s The Clean Code Talks: A Google Tech Talk. These are both great resources for developers. There really aren’t many places to go to learn software development beyond the basics. I think 99% of all the books out on software development are beginner books, and it’s really hard to find good material for professional software developers who are looking to further their craft. These are both excellent resources for developers waning to improve their craft.

But our discussion of CLEAN code won’t touch on either of these resources because I’ve done what we developers are great at doing: I’ve overloaded the term to mean something else entirely.

Before you throw tomatoes, virtually speaking, I’d just like to point out that this is how we make concepts memorable and understandable. Software development, and language in general, is full of overloaded terms and yes, there is room for one more.

So there it is: Write CLEAN Code. In the next several posts let’s talk about what CLEAN really means.

To view or add a comment, sign in

More articles by David Scott Bernstein

  • Green Tests and Red Tests

    In practice, I found that there are times that I want a bit more test coverage than I get from just doing test-first…

  • Radiators and Silos

    In the old days of corporate America, the way you got ahead was through hard work and perseverance. You strove to…

    2 Comments
  • Makers and Menders

    I’ve been getting back into some research interests of mine that require data acquisition from a variety of sensors so…

  • Core Developer Practices

    Every field of engineering has a core set of practices that they follow and software engineering is no different. But…

    1 Comment
  • Still XP After All These Years

    Are you humming in your head Paul Simon’s “Still Crazy After All These Years”? I am. And it does seem crazy.

  • The Importance of Continuous Integration

    Perhaps the most important yet easiest to implement of all the software development practices in Agile is continuous…

  • The Importance of Technical Practices (Again)

    Software development has undergone many revolutions over the last few decades. The way we build software today is…

  • Summary of Seven Strategies Series

    I finished my “Seven Strategies” series of 72 blog posts with seven strategies for implementing each of the nine…

    1 Comment
  • Refactor to Learn What Not to Do

    One of the things that I was not expecting when I started refactoring other people’s code was that I started to see…

    4 Comments
  • Refactor to Clean Up Before Moving On

    Of course, the best time to refactor code is while it’s fresh in your mind, right after having worked with it. Once I…

Others also viewed

Explore content categories