SE450: Architectural Patterns: Model-View-Controller [10/10] ![]() ![]() |
Comes from the Smalltalk-80 user interface design of user interfaces
Model - application object, the core data and functionality of the application. The model should not know about which view is using it. This allows you to move from a Text User Interface (TUI) to a Graphical User Interface (GUI) without changing the Model.
View - screen presentation. This could be a command line interface, a JSP/Servlet, a Swing Application, or a backend interface. The view will know about the Model, but doesn't necessarily have to have a reference to the model directly.
Controller - defines the way the View reacts to user input. Also decides whether requests are sent to the view or model. Should know about (and enforce) the relationships between views. Should decide whether a model gets updated or not. Many times, the Model will use a Command pattern to accept changes from the View.
Based on subscribe/notify. The view can subscribe to the model, and ensure that it will get notified. This is the Observer pattern. Views can be nested, in a CompositeView (using the Composite pattern). The View relates to the Controller via the Strategy design pattern. Factory Method can be used to specify the default controller class for a view, and Decorator could add scrolling or other GUI elements to a view.
Example files are here