The state of a program changes over time, as new objects get created and existing objects are modified. The program may respond to some of these change events. For example, a large deposit to a foreign-owned bank account might initiate a process that checks for illegal activity. The program may also respond to certain input events such as mouse actions and keyboard entries. For example, a mouse click on a button is normally responded to, but a mouse click on a label is often ignored.
The use of observers is a general-purpose technique for managing a program’s responses to events. An object can maintain ...