29.11.2014 Views

Smalltalk and Object Orientation: an Introduction - Free

Smalltalk and Object Orientation: an Introduction - Free

Smalltalk and Object Orientation: an Introduction - Free

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Edit button, then the user interface builder is Launcher for the given specification. If the Start button is<br />

selected then <strong>an</strong> inst<strong>an</strong>ce of the application class is created <strong><strong>an</strong>d</strong> opened on the specified specification.<br />

Figure 27.13: The Resource Finder<br />

The Resource Finder is a useful way of finding the specifications provided for various classes,<br />

menus, starting applications <strong><strong>an</strong>d</strong> editing existing applications.<br />

27.9 ValueHolders<br />

In VisualWorks the biggest departure from the original ParcPlac e version of <strong>Smalltalk</strong>, which was<br />

known as <strong>Smalltalk</strong> -80 <strong><strong>an</strong>d</strong> then <strong>Object</strong>Works, is the use of ValueHolders. ValueHolders represent a<br />

modification to the way information is exch<strong>an</strong>ged within the MVC architecture. This modification is<br />

intended to further buffer the user interface from the application model. The idea is that the model<br />

should present only that - a data structure <strong><strong>an</strong>d</strong> its associated methods. However in the MVC<br />

architecture, information about the interface often crept into the model. For example, the model would<br />

have to send the ch<strong>an</strong>ge message to itself at the right times <strong><strong>an</strong>d</strong> make the appropriate information<br />

available to the view (when the view received the resulting update: message). The use of<br />

ValueHolders is <strong>an</strong> attempt to remove this concern from the model.<br />

aView<br />

aController<br />

aModel<br />

aValueHolder<br />

<strong>an</strong><strong>Object</strong><br />

Figure 27.14: The modified MVC architecture in VisualWorks<br />

27.9.1 How they work<br />

The ValueHolder acts as <strong>an</strong> intermediate object whic h buffers the application model from the actual<br />

objects it maintains. The model now refers to ValueHolders, which refer to the actual objects being<br />

modeled (this is illustrated in Figure 27.14). Thus the model does not make direct reference to other<br />

objects, instead it refers to a ValueHolder. When the model w<strong>an</strong>ts to access a value it requests that the<br />

ValueHolder provides it. Similarly, if it w<strong>an</strong>ts to update a value it sends a message telling the<br />

ValueHolder to update its value.<br />

When the object referred to by a ValueHolder ch<strong>an</strong>ges, it is the responsibility of the ValueHolder to<br />

inform the associated view that its value has ch<strong>an</strong>ged <strong><strong>an</strong>d</strong> that the view should display this new value (in<br />

the original MVC it was the responsibility of the model). Similarly, if the controller receives input from<br />

the user which directly ch<strong>an</strong>ges the value of the ValueHolder, the controller merely informs the value<br />

holder that its value should ch<strong>an</strong>ge.<br />

231

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!