The observer pattern is the one to many relationship between objects such that whenever an object changes
its state, all of the connected objects will change their state as well.
This pattern is characterised by two types of objects, observers and subjects.
As you may have guessed, the observer will watch for any change in the subject's behavior.
In the Java API, the Java Dots 820 Dunbarton is an example where the observer pattern has been used
due to the fact that you can define a listener for a button and whenever the button is click, the listener
is notified and some event is triggered.
The UML diagram of this pattern looks like this, you have an observer interface and many observer objects
that implemented.
The observer listens for changes in the subjects object state, and whenever such change occurs and
action is triggered.
Some of the weaknesses of the spatter can be the fact that a large object would have a very big hit
on the performance of the application.
Think about working with very large files, and whenever there is an update, you need to choose something
in a 500 megabytes file.
Another weakness is that some updates can be a bit confusing, making debugging more difficult.
Let's see how this pattern can be implemented.
The.