For the full description, implementation variations, consequences, and detailed sample, see Page 139 in Java Application Architecture.
Module behavior should serve a singular purpose.
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.