Two hallmarks of good software design are low coupling and high cohesion. Cohesion is a measure of how focused a module of a program is on a set of responsibilities. Coupling is a measure of the degree to which the modules of a program are dependent on other modules.

Giving a module a broad set of responsibilities, or making it dependent on many other modules, makes the code more difficult to maintain and discourages code reuse. In other words, low cohesion and high coupling are detrimental to your application. Thus we should strive for high cohesion and low coupling: Restricting the focus of modules to closely related functionality, and minimizing their dependence on external code. 

I have discussed the various types of cohesion and coupling in a previous article (see “”). In this article I will look specifically at temporal coupling and suggest some strategies to avoid this particular design smell. 

What is temporal coupling?

Temporal coupling is a “design smell” that occurs when you have an implicit temporal relationship between two or more members of a class. This generally means having to invoke multiple members of a class in a specific sequence. The members are effectively tightly coupled because the calls must follow a strict order.