You are on page 1of 7

MVVM

Design Patterns
Collaboration
• Model
• The Data
• View
• Binding to ViewModel set by the DataContext
• ViewModel
• Exposes the Model as Properties and Commands
• Must implement INotifyPropertyChanged
Advantages of MVVM
• Reduce code-behind
• Model does not need to change to support a view
• Designers design, developers code
• Reduces development time
• Multi-targeting
Disadvantages of MVVM
• Create more files/classes
• Simple tasks can be complicated
• Lack of standardization
• Specific to WPF and Silverlight
MVVM
• 2004 – Martin Fowler – Presentation Model
• Separate a view from its state and behavior
• Not dependent on a specific UI framework
• 2008 – John Gossman – MVVM
• Identical to PM pattern
• Dependent on WPF/Silverlight
Intent of MVVM
• Separate Concerns
• UI (View)
• View’s state and behavior (ViewModel)
• Data (Model)
• Unit Testing and UI Testing
• Maintenance
• Extensibility
• Enable the designer/developer workflow
• Take advantage of data binding
Structure of MVVM
• View
• May or may not have a reference to the ViewModel
• Does NOT have a reference to the Model
• ViewModel
• Has a reference to the Model
• May or may not have a reference to the View
• Model
• Has no references to the View or ViewModel

You might also like