...

/

The Concept of Class Cohesion

The Concept of Class Cohesion

Understand the concept of class cohesion.

Class cohesion

In our previous example, it’s clear where the responsibilities should be split. In most cases, the decision is based on the same factor we have used—splitting responsibility based on atomic functional areas. In our case, the application is mainly responsible for processing text and managing files; therefore, we have two functional areas within it and end up with a separate class responsible for each of these.

However, there will be situations where a clear-cut functional area would be difficult to establish. Different functionalities sometimes have very fuzzy boundaries. This is where the concept of class cohesion comes into play to help us decide which classes to split and which ones to leave as they are.

Class cohesion measures how different public components of a ...