Package io.github.astrapi69.design.pattern.observer
The observer design pattern is a behavioral design pattern where an object, known as the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods This package contains the foundational components necessary for building systems based on the observer pattern, enabling objects to be notified of changes in other objects' states.
The key interfaces and classes in this package include:
AbstractObserver
- A base class that provides a concrete implementation of the observer interface, handling updates and executing commandsAbstractSubject
- A base class that provides a concrete implementation of the subject interface, managing observers and updating them when changes occur
This package is essential for creating systems where objects need to be informed of state changes in other objects, promoting loose coupling and dynamic behavior It demonstrates the flexibility and power of the observer design pattern in a wide range of application scenarios.
-
ClassesClassDescriptionA generic implementation of the Observer pattern This abstract class implements the
Observer
andActionCommand
interfaces, providing a basic framework for observers in the Observer design patternAbstractSubject<T,O extends Observer<T>> The classAbstractSubject
is an implementation of theSubject
interface This class encapsulates the observable object and notifies all registered observers when the observable changes