Cohesive Modules
For the full description, implementation variations, consequences, and detailed sample, see Page 139 in Java Application Architecture.
Statement
Module behavior should serve a singular purpose.
Description
There are two key elements that affect module cohesion. These follow:
- The rate at which the software entities within a module change.
- The likelihood that the software entities within a module are reused together.
Based on these statements, it’s easy to draw the following conclusion:
- Classes which change at different rates belong in separate modules.
- Classes that change at the same rate belong in the same module.
- Classes not reused together belong in separate modules.
- Classes reused together belong in the same module.
Unforunately, while logical, these general statements do not always apply.