21.07.2013 Views

User Interface Design and Ergonomics - National Open University of ...

User Interface Design and Ergonomics - National Open University of ...

User Interface Design and Ergonomics - National Open University of ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

MVC is frequently <strong>and</strong> needlessly convoluted by tying it directly to a graphical user<br />

interface. That a controller is <strong>of</strong>ten driven indirectly from a GUI is incidental. Likewise,<br />

rendering views graphically is an application <strong>of</strong> MVC, not part <strong>of</strong> the pattern definition.<br />

A business-to-business interface can leverage an MVC architecture equally well.<br />

3.2 HISTORY<br />

MVC was first described in 1979 by Trygve Reenskaug, then working on Smalltalk at<br />

Xerox PARC. The original implementation is described in depth in the influential paper<br />

"Applications Programming in Smalltalk-80: How to use Model–View–Controller".<br />

There have been several derivatives <strong>of</strong> MVC. For example, Model View Presenter is used<br />

with the .NET Framework, <strong>and</strong> the XForms st<strong>and</strong>ard uses a "model-view-controllerconnector<br />

architecture". However, st<strong>and</strong>ard MVC remains popular.<br />

3.3 PATTERN DESCRIPTION<br />

Model–view–controller is both an architectural pattern <strong>and</strong> a design pattern, depending<br />

on where it is used.<br />

3.3.1 AS AN ARCHITECTURAL PATTERN<br />

It is common to split an application into separate layers that can be analyzed, <strong>and</strong><br />

sometimes implemented, separately.<br />

MVC is <strong>of</strong>ten seen in web applications, where the view is the actual HTML or<br />

XHTML page, <strong>and</strong> the controller is the code that gathers dynamic data <strong>and</strong><br />

generates the content within the HTML or XHTML. Finally, the model is<br />

represented by the actual content, which is <strong>of</strong>ten stored in a database or in XML<br />

nodes, <strong>and</strong> the business rules that transform that content based on user actions.<br />

Though MVC comes in different flavors, control flow is generally as follows:<br />

The user interacts with the user interface in some way (for example, presses a<br />

mouse button).<br />

The controller h<strong>and</strong>les the input event from the user interface, <strong>of</strong>ten via a<br />

registered h<strong>and</strong>ler or callback.<br />

The controller notifies the model <strong>of</strong> the user action, possibly resulting in a change<br />

in the model's state. (For example, the controller updates the user's shopping cart.)<br />

A view uses the model indirectly to generate an appropriate user interface (for<br />

example, the view lists the shopping cart's contents). The view gets its own data<br />

from the model. The model <strong>and</strong> controller have no direct knowledge <strong>of</strong> the view.<br />

The user interface waits for further user interactions, which restarts the cycle.<br />

Some implementations such as the W3C XForms also use the concept <strong>of</strong> a<br />

dependency graph to automate the updating <strong>of</strong> views when data in the model<br />

changes.<br />

By decoupling models <strong>and</strong> views, MVC helps to reduce the complexity in<br />

architectural design <strong>and</strong> to increase flexibility <strong>and</strong> reuse <strong>of</strong> code.<br />

143

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

Saved successfully!

Ooh no, something went wrong!