Special

Clearance Sale!

We've been publishing for over five years now and it's time to clear out our inventory of back issues, so we're slashing prices!

RBD Magazines

Check out this amazing clearance sale of all our past issues. Missing some issues? This is a great time to complete your RBD collection. Save up to 40% off the regular price of our printed back issue packages. These prices are only good until the end of the year May 2008 and supplies are limited, so place your order today.

Article Preview


Buy Now

Print:
PDF:

Object-Oriented Thinking

Implementing a MessageCenter Module

Decoupling The Observer Pattern

Issue: 3.6 (July/August 2005)
Author: Charles Yeomans
Author Bio: Charles Yeomans is a software developer in Lexington, Kentucky.
Article Description: No description available.
Article Length (in bytes): 4,817
Starting Page Number: 35
RBD Number: 3616
Resource File(s): None
Related Link(s): None
Known Limitations: None

Excerpt of article text...

Your application allows users to customize its user interface and other behavior. A user can change the font, change colors, load different skins, and so forth. This means that many controls and objects need to know when settings are changed.

A standard solution to such a problem is described by the Observer pattern. In this pattern, objects that wish to be notified of some change to an object's state register their interest with the object. This object then notifies observers when a change occurs.

This can, however, require a considerable amount of code to add support for notification. In the case I have sketched, however, UI widgets are presumably already checking some other object to determine the correct settings. All that's needed is some means to tell them to recheck the settings of interest.

We can accomplish this by moving notification into a third object. Objects send messages to a message center, which in turn forwards the message to other objects that have asked to receive it. Let's define three things. First is a Message class. Second is a MessageReceiver class interface. Third is a MessageCenter module.

...End of Excerpt. Please purchase the magazine to read the full article.

Article copyrighted by REALbasic Developer magazine. All rights reserved.


 


|

 


Weblog Commenting and Trackback by HaloScan.com