Modularity and Software Cost

As the number of modules increases, the implementation cost per module decreases because the modules become simpler. But at the same time the interface cost per module increases because there are more modules to control and communicate with. As a result, we cannot say more modules always lead to better design. There is an "optimal" region of minimum cost.

Cohesion

Cohesion is a measure of the relative functional strength of a module, or the degree to which a module performs a single, isolated task.

High cohesion is good.

  • functional cohesion (a module has functional cohesion if it performs exactly one action or it achieves a single goal)
  • informational cohesion (a module has informational cohesion if it performs a number of an actions, each with its own entry point, with independent code for each action, all performed on the same data structure. Such a module is an implementation of abstract data type)
  • communicational cohesion (a module has communicational cohesion if it performs a series of actions related by the sequence of steps to be followed by the product and if all the actions are performed on the same data)
  • procedural cohesion (a module has procedural cohesion if it performs a series of actions related by the sequence of steps to be followed by the product)
  • temporal cohesion (a module has temporal cohesion when it performs a series of actions related in time)
  • logical cohesion (a module has logical cohesion if it performs a series of actions, one of which is selected by the calling module)
  • coincidental cohesion (a module has coincidental cohesion if it performs multiple, completely unrelated actions)

    Low cohesion is bad.

    When there are several answers, pick the worst one - the one with lowest cohesion.