Probably the widest cited pattern in user interface design is the Model View Controller (MVC), which is also the most distorted. I lost count of the time when I saw something described as MVC, which turned out to be different. Honestly, the reason is that parts of the classic MVC these days do not make sense to wealthy clients. But at the moment we will consider its origin.
As we look at MVC, it is important to remember that this was one of the first attempts to make a serious user interface for any scale. Graphical user interfaces were not exactly distributed in the 70s. The Forms and Controls model that I just described appeared after MVC — I described it first, because it is simpler, not always in a good way. Consider MVC Smalltalk 80 again using the evaluation example - but keep in mind that I accept several freedoms with Smalltalk 80 factual data to do this - for a start, it was a monochrome system.
At the heart of MVC and the idea that was most influential for later frameworks is what I call the Separated Presentation. The idea behind Separated Presentation is to make a clear separation between domain objects that model our perception of the real world and presentation objects that are GUI elements that we see on the screen. Domain objects should be completely autonomous and work without a link to the presentation; they should also support several presentations, possibly simultaneously. This approach has also been an important part of the Unix culture and continues today to allow many applications to be manipulated, either graphically or on the command line.
In MVC, a domain element is referred to as a model. Model objects completely ignore the user interface. To start a discussion of our example of UI evaluation, we take the model by reading, with fields for all the interesting data. (As we shall see, the presence of a list box makes this question about which model is more complex, but we will ignore this list a little.)
In MVC, I assume the domain model of ordinary objects, and not the representation of the record set that I had in forms and controls. This reflects the general assumption behind the design. Forms and controls assumed that most people want to easily manipulate data from a relational database, MVC assumes that we are manipulating regular Smalltalk objects.
The presentation part of MVC consists of two remaining elements: view and controller. The task of the controller is to accept user input and figure out what to do with it.
At this point, I have to emphasize that there is not only one type and controller, you have a pair of control points for each screen element, each control and the screen as a whole. Thus, the first part of the reaction to user input is the various controllers that work together to find out who has been edited. In this case, this is a text field in which the text controller will now process what comes next.
Figure 4: Main dependencies between model, view and controller. (I call this essential, because in fact the view and the controller are directly related to each other, but the developers mostly do not use this fact.)
As with subsequent environments, Smalltalk found out that you need common user interface components that can be reused. In this case, the component is the view-controller pair. Both were generic classes, so they needed to be connected to the specific behavior of the application. There will be an assessment view that will represent the entire screen and define the layout of the lower level controls, in this sense, similar to the form in Forms and Controllers. However, unlike the form, MVC does not have event handlers in the evaluation controller for the lower level components.
Figure 5: Classes for the MVC version of the ice cream monitor display
The configuration of a text field comes from giving it a link to its model, reading and indicating to it which method to call when changing text. When the screen is initialized, “#actual:” is set (the leading “#” denotes a character or interned string in Smalltalk). The text field controller then makes a reflexive call to read this method to make changes. In essence, this is the same mechanism as for data binding, the control is associated with the base object (string) and told which method (column) it manipulates.
Figure 6: Actual value change for MVC.
Thus, there is no common object that watches low-level widgets; instead, low-level widgets observe a model that itself processes many of the decisions that will be made by the form. In this case, when it comes to clarifying the variance, the reading object itself is a natural place for that.
Observers occur in MVC, indeed, this is one of the ideas credited to MVC. In this case, all views and controllers monitor the model. When the model changes, the views react. In this case, the actual representation of the text field is notified that the reading object has been changed, and calls the de