InterviewSolution
| 1. |
What is an Observer Design Pattern? |
|
Answer» An observer design pattern is a type of behavioural design pattern that is used for defining the one to many dependencies between the OBJECTS. It is most useful when we WANT to get notified about any change in the state of an object. In this pattern, when the state of one object changes, all the dependent objects are notified automatically. The object whose state is monitored is CALLED the Subject whereas the dependents are called the Observers. In Java, we can implement this pattern by making use of the java.util.Observable class and the java.util.Observer interface. The following UML diagram represents the observer design pattern clearly: This design pattern has 3 main components:
|
|