Observer Pattern | Learn for Master
  • Design Pattern: Observer Pattern in Java

    observer pattern

    We use simple examples and diagrams to describe the concept of observer pattern. We also give a simple implementation of the observer pattern in Java. 

    What is Observer Pattern

    The observer pattern defines a one-to-many relationship between two kinds of objects. The one side is called Subject, which maintains a list of Objects (called observers), and automatically notify each of the observers if something interesting happens. 

    The definition of the Observer pattern provided in the GoF book, Design Patterns: Elements of Reusable Object-Oriented Software, is:

    “One or more observers are interested in the state of a subject and register their interest with the subject by attaching themselves.

    [Read More...]