Solution: Building a Model-View-Controller System
To build the solution to the problem in the previous section, divide your interactive application into three components:
- A model that contains the data and core functionality
- Views that display information to the user
- Controllers that handle user input and tell the views what the user wants to display
Crediting MVC's inventor
A funny thing about most pattern authors and other members of the pattern community is that they don't want to take credit for something that they didn't invent. The Model-View-Controller pattern is a perfect example of this phenomenon. The concepts behind this pattern were developed by Trygve Reenskaug, but many people first saw them in the Smalltalk language, and others saw them in Pattern-Oriented Software Architecture: A System of Patterns, by Frank Buschmann, Regine Meunier, Hans Rohnert, Peter Sommerlad, and Michael Stal (Wiley) or in Patterns of Enterprise Application Architecture, by Martin Fowler (Addison-Wesley Professional). If you're curious, the original report about MVC that Reenskaug wrote for Xerox Palo Alto Research Center (PARC) is on his website at http://heim.ifi.uio.no/~trygver/1979/mvc-1/1979-05-MVC.pdf.
Exploring the effects of MVC
The MVC pattern has been used many times to structure interactive systems. The architects who have used it have seen the benefits and liabilities listed in the following sections.
Benefits
The flexibility of decoupling the data (model) from the output ...
Get Pattern-Oriented Software Architecture For Dummies now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.