CLEAN stands for five key code qualities that improve software’s maintainability. They are cohesive, loosely coupled, encapsulated, assertive, and non-redundant. These five code qualities make software more straightforward to work with.

Create CLEAN Code

Coupling and Testability

I can learn a lot about the kind of coupling in a system by listening to how people talk about testing it. If someone says, “I couldn’t test that without instantiating half the system,” then I know they have some coupling issues. Unfortunately, most systems I have seen—and most systems I know other people have …

Read More
Create CLEAN Code

Pathologies of Tight Coupling

We continue our conversation on code qualities with a discussion of why tight coupling is undesirable. Again, I want to stress, as I did in the last post, that we’re not striving for no coupling in a system. A system with no coupling is a system that does nothing. We want the right kind of …

Read More
Create CLEAN Code

Cohesion and Testability

I feel like I try to go around and get developers to do little things that will make a big difference in their work. For example, if you need to add some behavior to your system, rather than putting that behavior into some pre-existing entity, you should probably create a new class for that new …

Read More
Create CLEAN Code

Pathologies of Uncohesive Code

Uncohesive code is code that either has too many responsibilities or has poorly defined responsibilities. Typically, it’s code that tries to do too much. Poorly cohesive classes are difficult to understand and maintain. They’re harder to debug and more difficult to extend. The bottom line is the more issues a class has to deal with, …

Read More
Create CLEAN Code

Quality Code is Cohesive

The first code quality we’ll discuss is my very favorite: cohesion. Cohesive code is highly focused code that’s straightforward and easy to read. I like cohesion because it’s the easiest one for me to spot, but I recognize that that’s not true for everyone. People have told me that cohesion is actually the hardest for …

Read More
Create CLEAN Code

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 …

Read More
Create CLEAN Code

Quality in Software

Quality is a word we throw around a lot, but without much consensus on what it really means. And it can mean different things in different contexts. Quality in software is very different—the word has a fundamentally different meaning—from quality in goods or services. This is because software is fundamentally different than goods or services. …

Read More
Create CLEAN Code

Duplication versus Redundancy

You may have noticed that I don’t use the XP term duplication when talking about code quality. I prefer to use the term redundancy instead. This is because duplication is the most obvious form of redundancy but redundancy can take many other forms that are far subtler and harder to detect. When I ask developers …

Read More
Create CLEAN Code

Programming by Intention

In my blog post The Single Level of Responsibility Principle, I talked about the virtues of separating out perspectives in code so that any entity is only dealing with a single perspective. In this post, I’d like to tell you about the practice I use that helps me separate out perspectives in code without even …

Read More
Create CLEAN Code

The Single Level of Abstraction Principle

It’s virtuous to separate out different perspectives in code because it helps make code more testable, extendable, and understandable. We want to use entities at the same level of perspective so that code is easier to read and understand code. The same thing is true within entities where we want to do tasks at the …

Read More
Create CLEAN Code

Seven Strategies for Increasing Code Quality

People define quality in software in many ways. Some define quality as software that does what the customer wants. Others define quality as software that runs fast. Still others define quality as software that’s error-free. We all agree these are good things but are they all effects of a single cause, and if so, how …

Read More
Create CLEAN Code

What is Quality?

How do you define quality? Ford says that quality is job one but what is it and how do we create quality? We all recognize quality service at a fine restaurant and a quality product like a fine piece of furniture but what is quality in software? I ask this question a lot to developers …

Read More