Fundamentals of Modifiability – Cohesion & Coupling
Let us now get back to the main topic of modifiability, and discuss the two fundamental aspects that affect modifiability of code—namely, cohesion and coupling.
We've already discussed these concepts briefly in the first chapter. Let us do a quick review here.
The cohesion refers to how tightly the responsibilities of a module are related to each other. A module which performs a specific task or group of related tasks has high cohesion. A module in which a lot of functionality is dumped without a thought as to the core functionality would have low cohesion.
The coupling is the degree to which the functionality of two modules A and B are related. Two modules are strongly coupled if their functionality overlaps strongly at the code level—in terms of function or method calls. Any changes in module A would probably require changes in module B.
Strong coupling is always prohibitory for modifiability, as it increases the cost of maintaining...