GoF-Observer Pattern

Details
Full Name

GoF Observer Pattern (Behavioral)

Also known as

Publish-Subscribe, Event-Listener

Intent:

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

When to Use:

  • When changes to one object require changing others, and you don’t know how many objects need to change

  • When an object should notify others without knowing who they are

Prompt Example:

"Implementiere ein Event-System nach dem GoF-Observer Pattern, damit Änderungen am Datenmodell automatisch die UI aktualisieren."