O'Reilly logo

Design Patterns in Java™, Second Edition by William C. Wake, Steven John Metsker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

9 Observer

CLIENTS ORDINARILY gather information from an interesting object by calling its methods. But when an interesting object changes, a problem arises: How do clients that depend on the object’s information find out that the information has changed?

You may encounter designs that make an object responsible for informing clients when there is an interesting change in some aspect of that object. The problem with this is that the knowledge of which attributes about an object are interesting lies with the client. The interesting object shouldn’t accept responsibility for updating the client. One solution is to arrange for clients to be informed when the object changes and leave it to the clients to follow up with interrogations about the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required