Consequences of Using the Observer Pattern
In this lesson, we will explain the consequences of using the State pattern.
We'll cover the following...
Consequences
The main consequences of applying the Observer pattern are:
-
Introduces loose dependencies: As the subject only knows its observers through the Observer interface, the code conforms to the open-closed principle. We may introduce any number and any types of observers that support the Observer interface by avoiding hard-coded notifications. New behavior, in the form of new types of observers, is added without modifying existing code. The loose dependencies provide a way to communicate between layers in a sub-system. Design Patterns recognizes this potential: “Because Subject and Observer aren’t tightly coupled, they can belong to different layers of abstraction in a system. A lower-level ...