Consider a poorly-designed interface in which there are two functions (say foo() and bar()) that can be called independently, but in order to get some expected behavior (or in order to keep the object status consistent) the users have to call function bar() each time they call function foo().

Some examples:

interface SearchBinaryTree<T> {
    public add(T item): void;
    public rebalance(): void;

If add() just inserts an item in the tree this interface is not properly designed, because the responsibility to rebalance the tree is left to the user which may forget to call rebalance() after.

Another example:

interface VideoGame {
    public reset(): void;
    public play_level(level_no: number): void;

play_level() should work even if reset() was not called before, otherwise this interface is not properly designed.

Note that this time the problem is not the existence of the function reset() itself, rather than the fact that play_level() does not call it internally.

I'm interested in this kind of error: computer science students often make this mistake when designing their interfaces or API mostly because they don't understand how programming by contract works and they think that defining methods in the interfaces is just a way to split the code.

UX designers sometimes make this mistake too, for example by requiring to manually press the a button (say reset) before doing some other action (say insert the level number and click play) that must be done after pressing that button. The correct interaction in this case should be that the user just inserts the level number and clicks play; the application internally resets its variables and then loads the level.

Is there a name for this kind of error?

1 Answer 1


This is called temporal coupling. A phenomenon that occurs when two (or more) methods have to be called in a specific order.

  • I see, thank you. Is there any specific name for this kind of error or is it just a "badly coupled" interface?
    – melfnt
    Aug 27, 2020 at 9:37
  • 2
    Well, the name of the error, or rather design smell, is temporal coupling. You could see it as coupling in the temporal (time) dimension. One could say: "We should change this interface because it contains temporal coupling between methods A and B".
    – Rik D
    Aug 27, 2020 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.