© Edward Sciore 2019
Edward ScioreJava Program Designhttps://doi.org/10.1007/978-1-4842-4143-1_10

10. Observers

Edward Sciore1 
(1)
Newton, MA, USA
 

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 ...

Get Java Program Design: Principles, Polymorphism, and Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.