Design: Observer Pattern Implementation
Design and implement the core observer pattern components including subject and observers. Out of scope are UI frameworks or network communication.
Functional Requirements
FR1: Allow multiple observer objects to subscribe to a subject object.
FR2: Notify all subscribed observers automatically when the subject's state changes.
FR3: Support adding and removing observers at runtime.
FR4: Ensure observers receive updates in a timely manner after state changes.
FR5: Keep the subject and observers loosely coupled.
Non-Functional Requirements
NFR1: The notification latency should be minimal (under 100ms) for typical state changes.
NFR2: Support up to 1000 observers per subject without significant performance degradation.
NFR3: Ensure thread safety if multiple threads update the subject or observers.
NFR4: Memory usage should be efficient to handle many observers.
