Intentional Dependency

The majority of this chapter is concerned with how to avoid dependencies between components. The last topic that the chapter discusses is how to handle the situation where components must depend upon each other, and yet the programmer wants to make the connections as weak and tenuous as possible so as to permit components to be moved from one project to another. This is termed intentional dependency.

One technique that has become popular in the object-oriented world is to have dependencies mediated by an object in the middle, a dependency manager. Viewers tell the dependency manager what object they want to examine. The viewed objects, often termed the model, tell the dependency manager when they have changed. The dependency manager then alerts the viewers that the model has changed, and they should update themselves. In this fashion the model need not be aware of who or how many viewers it might have.

This makes for a very weak form of dependency, and in the control of complexity, weak is in this case good.

[audio] [real] Text to accompany slide14, in Chapter 17 of An Introduction to Object-Oriented Programming