Quality Code Is Cohesive

First and foremost, high-quality code is cohesive—each piece is about one thing. This is my favorite code quality because cohesive code is easy for most of us to understand and work with. It’s also easy to create.

If you look up the word cohesion in a dictionary you’ll find it’s a synonym for adhesion, or how well things are stuck together. But to software developers cohesion means software entities (classes and methods) should have a single responsibility.

Al Shalloway says, “No God Objects!”

When I asked Al, “You call it a God Object because it tries to do everything, right?” he said, “No, I call it a God Object because when you go to change it you say, ‘Oh, my God!’ ”

Scott Bain told me, “Keep entities single-minded.” ...

Get Beyond Legacy Code now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.