Create CLEAN Code

Quality Code is Encapsulated

To encapsulate something is to envelope and protect it. Encapsulation is a fundamental facility that every programming language supports at some level. Encapsulation is about hiding implementation details so ideas can be expressed at higher levels and to protect those details from other parts of the system. To me, most fundamentally, encapsulation means hiding implementation …

Read More
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
Bits and Pieces

Quality Code is Loosely Coupled

While cohesion, which was the subject of the last three posts, is about the internal consistency of a class or method, coupling is a code quality that looks at the relationship between entities. There are two distinct forms of coupling: loose coupling and tight coupling. One is good, the other isn’t—and I always forget which …

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