DEV Community

Cover image for Understanding Cohesion
Waqas Younis
Waqas Younis

Posted on

Understanding Cohesion

I just finished learning about Cohesion and it's part and here is a summary.

What is it?

It is how your module is structured, not how it communicates/integrates with another module. That is a couple.

There are 7 types of Cohesion

The best one is Function Cohesion, where everything that helps do a specific well-defined task is kept in one module. Like an Authentication Module, which offers functionality like login, logout, forgot password, etc

The worst one is Coincidental Cohesion, where there is no specific relation between the elements, except that they are at the same place. Consider a Utility module that has all sort of functions like String Format, Printing Log, Creating New File, etc.

The other ones didn't look interesting to me, they were like different sides of the same coin.

Top comments (0)