Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

14. Design Patterns > The Logical Observer

The Logical Observer

Some design patterns, like the Strategy pattern we’ve been exploring, do seem to imply a canonical structure. The Observer, on the other hand, is a pattern that’s more about the way objects interact than about the way they’re structured, and there are several ways to implement it.

Let’s start by looking at the interactions the Observer pattern represents:

image

This actually requires three different processes:

1 REGISTRATION

The Observer tells the Subject that it’s interested in the changes.

image

2 NOTIFICATION

The Subject notifies all the Observers that the change has occurred.

image

3 UNREGISTRATION

The Observer tells the Subject that it’s no longer interested.

image

1
image

2
image

3
image


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint