Design Pattern
  • Introduction
  • What is singleton?
  • factory method design pattern
  • loose coupling VS tight coupling
  • Proxy pattern
  • abstracFactory
  • OOA & OOD
  • Decorator Design Pattern
  • Iterator Design Pattern
  • The Observer Pattern
  • Spring Singleton VS Java Singleton
Powered by GitBook
On this page
  • Intent:
  • Structure

Was this helpful?

The Observer Pattern

PreviousIterator Design PatternNextSpring Singleton VS Java Singleton

Last updated 5 years ago

Was this helpful?

Observer Pattern is one of the behavioral design pattern. Observer design pattern is useful when you are interested in the state of an object and want to get notified whenever there is any change. In observer pattern, the object that watch on the state of another object are called Observer and the object that is being watched is called Subject.

Intent:

  • Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.

  • Encapsulate the core(or common or engine) components in a Subject abstraction, and the variable(or optional or user interface) components in an Observer hierarchy.

  • The "View" part of Model-View-Controller

Structure

https://www.journaldev.com/1739/observer-design-pattern-in-java
https://dzone.com/articles/observer-pattern-java
https://sourcemaking.com/design_patterns/observer