The class diagram of the observer pattern is as follows:
The observer pattern relies on the following classes:
- Subject: This is usually an interface that must be implemented by the classes and should be observable. The observers that should be notified are registered using the attach method. When they no longer have to be informed about the changes, they are deregistered using the detach method.
- ConcreteSubject: This is a class that implements the subject interface. It handles the list of observers and it updates them about the changes.
- Observer: This is an interface that is implemented by the objects that should be updated ...