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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

uild a running user interface from the output of the user interface builder. Therefore by inheriting from<br />

ApplicationModel, the new class (called ToDoOrg<strong>an</strong>iser in Figure 27.6) is able to create user<br />

interfaces.<br />

You may note that in Figure 27.6 I also specified a ‘Selector’ called windowSpec. This is actually<br />

where the window specification will be placed. The selector is actually the name of a class side method<br />

defined within a class protocol called interface specs, which return s a windowSpecification. This is<br />

actually <strong>an</strong> array of widget specifications. This approach allows different windows to be defined for the<br />

same class <strong><strong>an</strong>d</strong> saved under different names. For example, we could construct a welcome window, <strong>an</strong><br />

input window <strong><strong>an</strong>d</strong> <strong>an</strong> o utput window for some class <strong><strong>an</strong>d</strong> call each of them by different selector names.<br />

We could then choose which window we wished to open using the openInterface: message. Note<br />

that by default it is the window defined by the specification held in windowSpec which is created in<br />

response to <strong>an</strong> open message. Therefore:<br />

• aToDoInterface open. This opens a window defined by the windowSpec class side<br />

method.<br />

• aToDoOrg<strong>an</strong>izer openInterface: #welcome. This opens the window defined by the welcome<br />

class side method”<br />

Once the window has been installed onto a class you now have the potential to create a graphical<br />

application.<br />

Figure 27.6: The Installer<br />

27.5 Application models versus domain models<br />

In the last chapter we talked about the MV C architecture <strong><strong>an</strong>d</strong> that the model was the element of the<br />

MVC which held the data. However, in this chapter we have introduced a new class called<br />

ApplicationModel (which if you are very observ<strong>an</strong>t you will have noticed in the last chapter was a<br />

subclass of M odel). So where does that leave the good old MVC? Is the ApplicationModel the<br />

original model from the MVC or is it something different?<br />

In fact when we talked about the MVC we did actually state that there may be very m<strong>an</strong>y objects<br />

involved in providing the functionality of the whole system, but that only one of them might act as the<br />

model in the MVC. Essentially, the use of <strong>an</strong> explicit ApplicationModel class is really<br />

acknowledgment of this. By creating a class which is intended to provide the behavior nec essary to<br />

create <strong><strong>an</strong>d</strong> m<strong>an</strong>age the graphic user interface the developer c<strong>an</strong> encapsulate all the user interface<br />

functionality they need in subclasses of this ApplicationModel.<br />

227

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

Saved successfully!

Ooh no, something went wrong!