Permanent and Temporal Coupling

Just a quick post on this, because I find these two concepts useful when talking about dependency injection.

Permanent Coupling: Where you can't imagine the object existing without this dependency. The crass example is "a person has a brain." These should be injected via an object's constructor and I'd expect to see them appear in the app's config files (Guice, Spring, Picocontainer, whatever)

Temporal Coupling: The dependency is a temporary collaborator of another object, but you can imagine the object being just fine without it. The example would be "a person uses a watch to tell the time" (no puns were injured to bring you this example) I would expect to see these temporary collaborators to be visible as part of a method signature. I humbly submit that injecting these dependencies in the constructor is a mistake.


Simon Stewart on Sunday, 05 October, 2008

Posted in: /tech

You may comment...


Categories