Mvc, mvp, mvvm.pptx


Published on

  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Mvc, mvp, mvvm.pptx

  1. 1. MVC, MVP, and MVVM A comparison of model- view separation architectural patterns1
  2. 2. 2 A pattern is a solution to a well-understood problem
  3. 3. 3 An architectural patternsolves architectureproblems
  4. 4. 4 The SmartUI pattern is where youhave logic in the code-behindPros Cons›  Fast ›  Rigid›  Easy to code ›  Resistant to change ›  Unforgiving
  5. 5. 5 MVC, MVP, and MVVM are allsolving this problem›  Get the logic out of the UI›  Loosely coupled›  Reusable›  Unit-testable›  UI designers can work on the UI
  6. 6. 6 Note that they all have a modeland a view
  7. 7. 7 The Model is pure business logic›  Completely unaware of the other components›  Very unit-testable
  8. 8. 8 The view deals with UI only›  Itdisplays data from the model›  Should be kept as thin as possible
  9. 9. Browser Controller How MVC works 10 Model View
  10. 10. Browser Presenter How MVP works 13 Model View
  11. 11. Browser l ViewMode 17 How MVVM works Model View
  12. 12. 20 MVC vs. MVPMVC MVP›  User hits the C first ›  Userhits the V first›  V can switch Cs ›  One V to One P›  C talks to V, but V cant ›  Two-way talk to C communication›  C has a reference to the between V and P V ›  V has a reference to the›  V has a reference to the P M ›  V cant see M
  13. 13. 21 MVC vs. MVVMMVC MVVM›  C is much more ›  VM is much simpler – It powerful than a VM just ties the V to the M›  User hits the C first ›  User hits the V first›  The view knows about ›  V cant see the M the model ›  V has an instance of the›  V gets an instance of VM the M ›  One VM per V
  14. 14. 22 MVVM vs. MVPMVVM MVP›  M is a business object ›  M is a UI thing, not a business thing
  15. 15. 23 So which should I choose?›  MVC is best for web applications›  MVP is best for windows forms›  MVVM is best for WPF and Silverlight
  16. 16. 24 Conclusion›  All three architectural patterns solve the problems of rigidity and fragility›  They are significantly more work for small projects›  But they pay for themselves with larger projects once you learn the patterns
  17. 17. 25 Further study› mvvm-vs-mvp-vs-mvc-the-differences-explained/› overview-of-the-modelview-viewmodel-mvvm- pattern-and-data-binding/› mvvm-patterns-along-with-their-respective- viewmodels› 2009/11/21/136454.aspx