Coupling and Cohesion
As we walk through the various scenarious, performing the who/what cycle
and assigning behaviors to different components, our actions should be
guided by the principles of coupling and cohesion.
-
Cohesion is the degree to which the tasks assigned to a component seem to
form a meaningful unit. Want to maximize cohesion by making certain that
all the actions assigned to a component seem to match each other in a
meaningful way.
-
Coupling is the degree to which the ability to fulfill a certain
responsibility depends upon the actions of another component. Want to
minimize coupling, by reducing the need for one component to depend
upon the actions of another in order to fulfill its responsibility.
Reducing coupling results in more robust systems, and speeds development
time since components can be created and tested in isolation, independent
from other components.