Fundamentals of modifiability – cohesion and coupling
Let's 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's do a quick review here.
Cohesion refers to how tightly the responsibilities of a module are related to each other. A module that 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.
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...