next up previous contents
Next: C. The CRV Data Up: Dissertation Previous: A1. The Definition of


B. Notifications

Notifications can be used for a loose coupling between objects. Listener objects subscribe to an event of the caller object by sending it a :send-on-event message. In Example B.1 the clients of a Cook want to receive a :go-for-lunch message when the Cook issues the lunch-is-ready event. Therefore, they register an appropriate notification at line 30 and 31.
\begin{Example}
% latex2html id marker 10451\centering\scriptsize
\begin{minip...
...ening for the event \textit{lunch-is-ready} of the
\textsl{Cook}.}
\end{Example}

After the cook finishes baking the lunch (in the :prepare-lunch method at line 10), he issues the lunch-is-ready event with the effect that Chris and Irmi receive their desired :go-for-lunch message. We see the corresponding screen outputs in Example B.2.


\begin{Example}
% latex2html id marker 10469\centering\scriptsize
\begin{minip...
...ption{
The screen output of
Example \ref{exa::notification-demo}.}
\end{Example}

Notifications are particularly useful if objects are forced to communicate asynchronously with each other. This is typically the case for graphical user interfaces or processes of the operating system, where callbacks are involved.



Rudi Strasser
1999-05-27