Observer Pattern
Murat Yener, Alex Theedom · 2014
The observer pattern is one of the most widely used and accepted design patterns in modern programming languages, software, and user interface (UI) frameworks. This chapter focuses on Java's default implementation of the observer pattern: where it is used, how observers are implemented via annotations in Java EE, and how observers can be made transaction sensitive. The observer pattern is based on the principle of inheritance and is one of the behavioral design patterns. Java provides an out-of-the-box implementation of the observer pattern. By implementing the Observer interface and extending the Observable class, developers can easily implement the observer pattern. The observer pattern, which can unleash huge performance gains, is an effective way to promote loose coupling and change the direction of calling/listening. The observer pattern's greatest strength, the decoupling of classes, is also its greatest weakness.