Model View View-Model (MVVM)
Model View View-Model (MVVM)
Agenda
• GUI Patterns
‣ Controls
‣ Containers/Dials/Widgets
‣ Panels/Windows
‣ Menus/Buttons/Dropdowns
• Fine-grained events
‣ Mouse entered, exited
‣ Mouse pressed
‣ Radio button pressed, armed, rollover
• Coarse-grained events:
‣ Radio button selected
‣ Action performed
‣ Domain property changed
4
GUI Patterns
• Reusable designs that can be realised with different toolkits:
‣ Notification
‣ Supervising Controller
‣ Passive View
‣ Presentation Model
‣ Event Aggregator
‣ Window Driver
‣ Flow Synchronization
‣ Observer Synchronization
In particular, read
‣ Presentation Chooser
http://martinfowler.com/eaaDev/uiArchs.html
for background to these patterns
‣ Autonomous View
5
Key Principle: Separation of Concerns
https://en.wikipedia.org/wiki/Separation_of_concerns
6
Model View Controller
• Controller defines the way the user interface reacts to user input
• Before MVC, user interface designs tended to lump these objects together.
MVC decouples them to increase flexibility and reuse
7
Synchronization
• A view must ensure that its appearance reflects the state of the model.
• Whenever the model's data changes, the model notifies views that depend
on it.
8
View / Model
9
Controller
10
MVC Sequence Diagrams
11
Potential Advantages
• Since MVC handles the multiple views using the same enterprise model it
is easier to maintain, test and upgrade the multiple system.
• It will be easier to add new clients just by adding their views and
controllers.
12
Model View View-Model
• Model: refers either to a domain
model, which represents real
state content
14