📗
Design Patterns with Examples
  • Introduction
  • Intro to Design Patterns
  • Iterator, Composition
  • Composition
  • Command
  • Decorator
  • Factory
  • Template Method
  • Adapter, Facade
  • Loose Coupling
  • Observer
Powered by GitBook
On this page
  • Design Principle
  • Loose Coupling

Was this helpful?

Observer

A one-to-many dependency between objects so that when an object changes state all its dependents are notified and updated automatically.

Subjects and Observers are loosely coupled. The Subject knows about a one-method interface that Observers implement. You can add Observers any time without any change needed to the Subject. When Subject changes state Observers get notified.

Subject and Observers can be used independently of each other in isolation. Changes to one does not affect the other.

Design Principle

Strive for loose coupling between objects that interact.

Loose Coupling

When two objects are loosely coupled they can interact but know very little about each other.

PreviousLoose Coupling

Last updated 5 years ago

Was this helpful?