Keep It CLEAN
In this post, one of our MVBs explains his acronym for creating great code, CLEAN, an how it aids in the development process.
Join the DZone community and get the full member experience.Join For Free
I like dirty martinis and R-rated movies but my code is one place I always want to keep it 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 of 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:
- Loosely coupled.
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 wanting to improve their skills.
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.
Published at DZone with permission of David Bernstein, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.