Il pattern Observer definisce una dipendenza uno-a-molti dove molteplici oggetti (observer) vengono notificati automaticamente quando un altro oggetto (il subject) cambia stato. Abilita una comunicazione disaccoppiata e guidata da eventi — ampiamente utilizzata in UI, sistemi di eventi e programmazione reattiva.
Cosa fa il pattern Observer
OBSERVER → a SUBJECT maintains a list of OBSERVERS and NOTIFIES them on state changes:
→ observers SUBSCRIBE to the subject
→ when the subject changes → it notifies ALL subscribed observers automatically
→ observers react to the notification (update themselves)
→ one-to-many: one subject, many observers; DECOUPLED (subject doesn't know observer details)
