SlideShare une entreprise Scribd logo
1  sur  26
MVC, MVP and MVVM Design
Patterns
A comparison
Mudasir Qazi - mudasirqazi00@gmail.com 111-Dec-14
Contents / Agenda
• Separation of Concerns
• MVC
• Definition and Architecture
• Explanation of Modules
• Sequence Diagram
• Advantages and Disadvantages
• MVP
• Definition and Architecture
• Explanation of Modules
• Sequence Diagram
• Advantages and Disadvantages
• MVVM
• Definition and Architecture
• Explanation of Modules
• Sequence Diagram
• Advantages and Disadvantages
• Summary (a comparison of all three patterns)
• One Last Tip
Mudasir Qazi - mudasirqazi00@gmail.com 211-Dec-14
Separation of Concerns
• All these methods do only one thing “Separation of Concerns” or
“Layered Architecture” but in their own way.
• All these concepts are pretty old, like idea of MVC was tossed in
1970s.
• All these patterns forces a separation of concerns, it means domain
model and controller logic are decoupled from user interface (view).
As a result maintenance and testing of the application become
simpler and easier.
Mudasir Qazi - mudasirqazi00@gmail.com 311-Dec-14
MVC Pattern Architecture
• MVC stands for Model-View-Controller.
Mudasir Qazi - mudasirqazi00@gmail.com 411-Dec-14
Explanation of Modules
Model:
• The Model represents a set of classes that describe the business logic i.e.
business model as well as data access operations i.e. data model. It also defines
business rules for data means how the data can be changed and manipulated.
View:
• The View represents the UI components like CSS, jQuery, html etc. It is only
responsible for displaying the data that is received from the controller as the
result. This also transforms the model(s) into UI.
Controller:
• The Controller is responsible to process incoming requests. It receives input from
users via the View, then process the user's data with the help of Model and
passing the results back to the View. Typically, it acts as the coordinator between
the View and the Model. There is One-to-Many relationship between Controller
and View, means one controller can handle many views.
Mudasir Qazi - mudasirqazi00@gmail.com 511-Dec-14
Sequence Diagram
Mudasir Qazi - mudasirqazi00@gmail.com 611-Dec-14
Advantages of MVC
• 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.
• Since the Model is completely decoupled from view it allows lot of
flexibilities to design and implement the model considering reusability and
modularity. This model also can be extended for further distributed
application.
• It is possible to have development process in parallel for model, view and
controller.
• This makes the application extensible and scalable.
• It is really effective with Microsoft’s ASP.Net and Entity Framework.
Mudasir Qazi - mudasirqazi00@gmail.com 711-Dec-14
Disadvantages of MVC
• Requires high skilled experienced professionals who can identify the
requirements in depth at the front before actual design.
• It requires the significant amount of time to analyze and design.
• This design approach is not suitable for smaller applications.
• In case of complicated user interface with states of views related to each
other and
• Possible workflow models, this information though not business
functionality related
• Has to be in the Model layer. In very large systems this may be beneficial,
otherwise it is usually transferred to the control layer, somewhat breaching
the pattern.
Mudasir Qazi - mudasirqazi00@gmail.com 811-Dec-14
MVP Pattern
Model-View-Presenter (MVP) is a variation of the Model-View-
Controller (MVC) pattern but specifically geared towards a page event
model.
The primary differentiator of MVP is that the Presenter implements an
Observer design of MVC but the basic ideas of MVC remain the same:
the model stores the data, the view shows a representation of the
model, and the presenter coordinates communications between the
layers.
Mudasir Qazi - mudasirqazi00@gmail.com 911-Dec-14
MVP Pattern Architecture
Mudasir Qazi - mudasirqazi00@gmail.com 1011-Dec-14
Explanation of Modules
Model:
The model in MVP is just the same, that is described earlier in the Model-View-
Controller pattern.
Presenter:
The Presenter’s responsibility is to handle user input and use this to manipulate the
model data. The interactions of the User are first received by the view and then
passed to the presenter for interpretation. Often, a presenter will maintain a
selection that identifies a range of data in the model that is current, and the
gestures received from the view will be used to act on this. There is One-to-One
relationship between View and Presenter, means each view will be handled by one
presenter.
View:
When the model is updated, the view also has to be updated to reflect the
changes. View updates can be handled in several ways.
Mudasir Qazi - mudasirqazi00@gmail.com 1111-Dec-14
Passive view and Supervising Controller
• The Model-View-Presenter variants, Passive View and Supervising
Controller, specify different approaches to implementing view updates.
• In Passive View, the presenter updates the view to reflect changes in the
model. The interaction with the model is handled exclusively by the
presenter. The view is not aware of changes in the model.
• In Supervising Controller, the view interacts directly with the model to
perform simple data-binding that can be defined declaratively, without
presenter intervention. The presenter updates the model; it manipulates
the state of the view only in cases where complex UI logic that cannot be
specified declaratively is required. .NET Data-binding technologies make
this approach more appealing for many cases, although if not carefully
designed it may result in coupling between view and model.
Mudasir Qazi - mudasirqazi00@gmail.com 1211-Dec-14
Sequence Diagram for MVP
Mudasir Qazi - mudasirqazi00@gmail.com 1311-Dec-14
Advantages of MVP
• As with Model-View-Controller, Model-View-Presenter has the advantage that it
clarifies the structure of our user interface code and can make it easier to
maintain.
• Not only do we have our data taken out of the View and put into the Model, but
also almost all complex screen logic will now reside in the Presenter.
• We have almost no code in our View apart from screen drawing code Model-
View-Presenter also makes it theoretically much easier to replace user interface
components, whole screens, or even the whole user interface (Windows Forms to
WPF for example).
• This makes the user opinion sensitive UI part perfectly separate of other parts of
the application, hence it’s features can be enhanced separately with more
involvement from the customer.
• In addition unit testing the user interface becomes much easier as we can test
the logic by just testing the Presenter.
Mudasir Qazi - mudasirqazi00@gmail.com 1411-Dec-14
Disadvantages of MVP
• Requires high skilled experienced professionals who can identify the
requirements in depth at the front before actual design.
• It requires the significant amount of time to analyze and design.
• This design approach is not suitable for smaller applications. It overkills the
small applications.
• It can be hard to debug events being fired in active Model-View-Presenter.
• The Passive View version of Model-View-Presenter can lead to a certain
amount of boilerplate code having to be written to get the interface into
the View to work.
• In both MVP and MVC cases the code for supporting the proper pattern
implementation can be complex, hence it is not advised to use in smaller
projects.
Mudasir Qazi - mudasirqazi00@gmail.com 1511-Dec-14
MVVM Pattern
• The Model-View-ViewModel (MVVM or ViewModel) is a pattern for
separating concerns in technologies that use data-binding.
• The first two pattern the MVC and MVP does not work as well as
MVVM in declarative user interfaces like Windows Presentation
Foundation or Silverlight because the XAML that these technologies
use can define some of the interface between the input and the view
(because data binding, triggers, and states can be declared in XAML).
• The MVVM pattern is an adaptation of the MVC and MVP patterns in
which the view model provides a data model and behavior to the
view but allows the view to declaratively bind to the view model.
Mudasir Qazi - mudasirqazi00@gmail.com 1611-Dec-14
MVVM Architecture
Mudasir Qazi - mudasirqazi00@gmail.com 1711-Dec-14
MVVM Architecture
Mudasir Qazi - mudasirqazi00@gmail.com 1811-Dec-14
Explanation of Modules
Model:
The model is especially important because it wraps the access to the data, whether
access is through a set of Web services, an ADO.NET Data Service, or some other
form of data retrieval. The model is separated from the view model so that the
view's data (the view model) can be tested in isolation from the actual data.
View:
The pattern we use is to set the Data Context of a view to its ViewModel. The view
classes have no idea that the model classes exist, while the ViewModel and model
are unaware of the view. In fact, the model is completely oblivious to the fact that
the ViewModel and view exist. A View is the actual UI behind a view in the
application. The elements of the UI are implemented in XAML, and as a result of
this the code behind file contains minimal code, or in some cases it does not
contain code at all, however it is different in Silverlight and WPF.
Mudasir Qazi - mudasirqazi00@gmail.com 1911-Dec-14
Continued…
ViewModel:
A ViewModel is a model for a view in the application as shown by its name. It
has a collection which contain the data from the model currently needed for
the view. Unlike the Presenter in MVP, a ViewModel does not need a
reference to a view. The view binds to properties on a ViewModel, which, in
turn, exposes data contained in model objects and other state specific to the
view. The bindings between view and ViewModel are simple to construct
because a ViewModel object is set as the Data Context of a view. If property
values in the ViewModel change, those new values automatically propagate
to the view via data binding. When the user clicks a button in the View, a
command on the ViewModel executes to perform the requested action. The
ViewModel, never the View, performs all modifications made to the model
data.
Mudasir Qazi - mudasirqazi00@gmail.com 2011-Dec-14
Sequence Diagram for MVVM
Mudasir Qazi - mudasirqazi00@gmail.com 2111-Dec-14
Advantages of MVVM
• Reduces the amount of code in the View’s code behind file.
• UI elements can be written in XAML
• Strong Data Binding, which saves a lot of code. No need for manually
refresh the view.
Mudasir Qazi - mudasirqazi00@gmail.com 2211-Dec-14
Disadvantages of MVVM
• In bigger cases, it can be hard to design the ViewModel up front in
order to get the right amount of generality.
• Data-binding for all its wonders is declarative and harder to debug
than nice imperative stuff where you just set breakpoints.
Mudasir Qazi - mudasirqazi00@gmail.com 2311-Dec-14
Summary (1)
Mudasir Qazi - mudasirqazi00@gmail.com 2411-Dec-14
Summary (2)
Mudasir Qazi - mudasirqazi00@gmail.com 2511-Dec-14
Last Word
• Must note the difference between the event responses of all patterns
in Sequence diagram. It clears the confusion about the response of
user input.
Mudasir Qazi - mudasirqazi00@gmail.com 2611-Dec-14

Contenu connexe

Tendances

Asp.net MVC training session
Asp.net MVC training sessionAsp.net MVC training session
Asp.net MVC training sessionHrichi Mohamed
 
ASP.NET MVC.
ASP.NET MVC.ASP.NET MVC.
ASP.NET MVC.Ni
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentationivpol
 
MVVM with WPF
MVVM with WPFMVVM with WPF
MVVM with WPFS V
 
MVx patterns in iOS (MVC, MVP, MVVM)
MVx patterns in iOS (MVC, MVP, MVVM)MVx patterns in iOS (MVC, MVP, MVVM)
MVx patterns in iOS (MVC, MVP, MVVM)Yaroslav Voloshyn
 
Introduction to React
Introduction to ReactIntroduction to React
Introduction to ReactRob Quick
 
Jetpack Compose beginner.pdf
Jetpack Compose beginner.pdfJetpack Compose beginner.pdf
Jetpack Compose beginner.pdfAayushmaAgrawal
 
Introduction to react_js
Introduction to react_jsIntroduction to react_js
Introduction to react_jsMicroPyramid .
 
Visitor Pattern
Visitor PatternVisitor Pattern
Visitor PatternIder Zheng
 
Android Navigation Component
Android Navigation ComponentAndroid Navigation Component
Android Navigation ComponentŁukasz Ciupa
 
MVC ppt presentation
MVC ppt presentationMVC ppt presentation
MVC ppt presentationBhavin Shah
 
Android Jetpack Compose - Turkey 2021
Android Jetpack Compose - Turkey 2021Android Jetpack Compose - Turkey 2021
Android Jetpack Compose - Turkey 2021Nelson Glauber Leal
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)Manisha Keim
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC PresentationVolkan Uzun
 
Angular 8
Angular 8 Angular 8
Angular 8 Sunil OS
 

Tendances (20)

Asp.net MVC training session
Asp.net MVC training sessionAsp.net MVC training session
Asp.net MVC training session
 
ASP.NET MVC.
ASP.NET MVC.ASP.NET MVC.
ASP.NET MVC.
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
 
MVVM with WPF
MVVM with WPFMVVM with WPF
MVVM with WPF
 
MVx patterns in iOS (MVC, MVP, MVVM)
MVx patterns in iOS (MVC, MVP, MVVM)MVx patterns in iOS (MVC, MVP, MVVM)
MVx patterns in iOS (MVC, MVP, MVVM)
 
SQLITE Android
SQLITE AndroidSQLITE Android
SQLITE Android
 
Introduction to React
Introduction to ReactIntroduction to React
Introduction to React
 
MVVM
MVVMMVVM
MVVM
 
Jetpack Compose beginner.pdf
Jetpack Compose beginner.pdfJetpack Compose beginner.pdf
Jetpack Compose beginner.pdf
 
React Native
React Native React Native
React Native
 
Introduction to react_js
Introduction to react_jsIntroduction to react_js
Introduction to react_js
 
Visitor Pattern
Visitor PatternVisitor Pattern
Visitor Pattern
 
Android Navigation Component
Android Navigation ComponentAndroid Navigation Component
Android Navigation Component
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
 
MVC ppt presentation
MVC ppt presentationMVC ppt presentation
MVC ppt presentation
 
Vue.js
Vue.jsVue.js
Vue.js
 
Android Jetpack Compose - Turkey 2021
Android Jetpack Compose - Turkey 2021Android Jetpack Compose - Turkey 2021
Android Jetpack Compose - Turkey 2021
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
 
Angular 8
Angular 8 Angular 8
Angular 8
 

Similaire à Design Pattern - MVC, MVP and MVVM

Models used in iOS programming, with a focus on MVVM
Models used in iOS programming, with a focus on MVVMModels used in iOS programming, with a focus on MVVM
Models used in iOS programming, with a focus on MVVMAndrei Popa
 
Using mvvm inside mvc in domain driven design
Using mvvm inside mvc in domain driven designUsing mvvm inside mvc in domain driven design
Using mvvm inside mvc in domain driven designyashar Aliabasi
 
MVVM presentation
MVVM presentationMVVM presentation
MVVM presentationInova LLC
 
Mvvw patterns
Mvvw patternsMvvw patterns
Mvvw patternseleksdev
 
Avigma Tech LLC- Why the MVC pattern so popular?
Avigma Tech LLC- Why the MVC pattern so popular?Avigma Tech LLC- Why the MVC pattern so popular?
Avigma Tech LLC- Why the MVC pattern so popular?Mike Brown
 
MVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,MobileMVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,Mobilenaral
 
Mobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesMobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesQamar Abbas
 
Android DesignArchitectures.pptx
Android DesignArchitectures.pptxAndroid DesignArchitectures.pptx
Android DesignArchitectures.pptxSafnaSaff1
 
Architectural Design Pattern: Android
Architectural Design Pattern: AndroidArchitectural Design Pattern: Android
Architectural Design Pattern: AndroidJitendra Kumar
 
iOS architecture patterns
iOS architecture patternsiOS architecture patterns
iOS architecture patternsallanh0526
 
Architectural Design & Patterns
Architectural Design&PatternsArchitectural Design&Patterns
Architectural Design & PatternsInocentshuja Ahmad
 

Similaire à Design Pattern - MVC, MVP and MVVM (20)

Models used in iOS programming, with a focus on MVVM
Models used in iOS programming, with a focus on MVVMModels used in iOS programming, with a focus on MVVM
Models used in iOS programming, with a focus on MVVM
 
Using mvvm inside mvc in domain driven design
Using mvvm inside mvc in domain driven designUsing mvvm inside mvc in domain driven design
Using mvvm inside mvc in domain driven design
 
MVVM presentation
MVVM presentationMVVM presentation
MVVM presentation
 
Ios models
Ios modelsIos models
Ios models
 
MVC
MVCMVC
MVC
 
Mvvw patterns
Mvvw patternsMvvw patterns
Mvvw patterns
 
Avigma Tech LLC- Why the MVC pattern so popular?
Avigma Tech LLC- Why the MVC pattern so popular?Avigma Tech LLC- Why the MVC pattern so popular?
Avigma Tech LLC- Why the MVC pattern so popular?
 
Mvc, mvp & mvvm (erp)
Mvc, mvp & mvvm (erp)Mvc, mvp & mvvm (erp)
Mvc, mvp & mvvm (erp)
 
MVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,MobileMVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,Mobile
 
Mobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesMobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelines
 
MVC.pptx
MVC.pptxMVC.pptx
MVC.pptx
 
Android DesignArchitectures.pptx
Android DesignArchitectures.pptxAndroid DesignArchitectures.pptx
Android DesignArchitectures.pptx
 
Knockout js
Knockout jsKnockout js
Knockout js
 
Android MVVM
Android MVVMAndroid MVVM
Android MVVM
 
Adopting MVVM
Adopting MVVMAdopting MVVM
Adopting MVVM
 
Architectural Design Pattern: Android
Architectural Design Pattern: AndroidArchitectural Design Pattern: Android
Architectural Design Pattern: Android
 
iOS architecture patterns
iOS architecture patternsiOS architecture patterns
iOS architecture patterns
 
Architectural Design & Patterns
Architectural Design&PatternsArchitectural Design&Patterns
Architectural Design & Patterns
 
J2 ee archi
J2 ee archiJ2 ee archi
J2 ee archi
 
MVC
MVCMVC
MVC
 

Plus de Mudasir Qazi

Design Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternDesign Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternMudasir Qazi
 
Database - SQL Joins
Database - SQL JoinsDatabase - SQL Joins
Database - SQL JoinsMudasir Qazi
 
Database - Normalization
Database - NormalizationDatabase - Normalization
Database - NormalizationMudasir Qazi
 
Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)Mudasir Qazi
 
OOP - Understanding association, aggregation, composition and dependency
OOP - Understanding association, aggregation, composition and dependencyOOP - Understanding association, aggregation, composition and dependency
OOP - Understanding association, aggregation, composition and dependencyMudasir Qazi
 
OOP - Polymorphism
OOP - PolymorphismOOP - Polymorphism
OOP - PolymorphismMudasir Qazi
 
OOP - Java is pass-by-value
OOP - Java is pass-by-valueOOP - Java is pass-by-value
OOP - Java is pass-by-valueMudasir Qazi
 
OOP - Benefits and advantages of OOP
OOP - Benefits and advantages of OOPOOP - Benefits and advantages of OOP
OOP - Benefits and advantages of OOPMudasir Qazi
 
Design Pattern - Singleton Pattern
Design Pattern - Singleton PatternDesign Pattern - Singleton Pattern
Design Pattern - Singleton PatternMudasir Qazi
 
Design Pattern - Observer Pattern
Design Pattern - Observer PatternDesign Pattern - Observer Pattern
Design Pattern - Observer PatternMudasir Qazi
 
Design Pattern - Introduction
Design Pattern - IntroductionDesign Pattern - Introduction
Design Pattern - IntroductionMudasir Qazi
 
Design Pattern - Factory Method Pattern
Design Pattern - Factory Method PatternDesign Pattern - Factory Method Pattern
Design Pattern - Factory Method PatternMudasir Qazi
 
Design pattern - Facade Pattern
Design pattern - Facade PatternDesign pattern - Facade Pattern
Design pattern - Facade PatternMudasir Qazi
 
Design Pattern - Chain of Responsibility
Design Pattern - Chain of ResponsibilityDesign Pattern - Chain of Responsibility
Design Pattern - Chain of ResponsibilityMudasir Qazi
 

Plus de Mudasir Qazi (14)

Design Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternDesign Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory Pattern
 
Database - SQL Joins
Database - SQL JoinsDatabase - SQL Joins
Database - SQL Joins
 
Database - Normalization
Database - NormalizationDatabase - Normalization
Database - Normalization
 
Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)
 
OOP - Understanding association, aggregation, composition and dependency
OOP - Understanding association, aggregation, composition and dependencyOOP - Understanding association, aggregation, composition and dependency
OOP - Understanding association, aggregation, composition and dependency
 
OOP - Polymorphism
OOP - PolymorphismOOP - Polymorphism
OOP - Polymorphism
 
OOP - Java is pass-by-value
OOP - Java is pass-by-valueOOP - Java is pass-by-value
OOP - Java is pass-by-value
 
OOP - Benefits and advantages of OOP
OOP - Benefits and advantages of OOPOOP - Benefits and advantages of OOP
OOP - Benefits and advantages of OOP
 
Design Pattern - Singleton Pattern
Design Pattern - Singleton PatternDesign Pattern - Singleton Pattern
Design Pattern - Singleton Pattern
 
Design Pattern - Observer Pattern
Design Pattern - Observer PatternDesign Pattern - Observer Pattern
Design Pattern - Observer Pattern
 
Design Pattern - Introduction
Design Pattern - IntroductionDesign Pattern - Introduction
Design Pattern - Introduction
 
Design Pattern - Factory Method Pattern
Design Pattern - Factory Method PatternDesign Pattern - Factory Method Pattern
Design Pattern - Factory Method Pattern
 
Design pattern - Facade Pattern
Design pattern - Facade PatternDesign pattern - Facade Pattern
Design pattern - Facade Pattern
 
Design Pattern - Chain of Responsibility
Design Pattern - Chain of ResponsibilityDesign Pattern - Chain of Responsibility
Design Pattern - Chain of Responsibility
 

Dernier

Novel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsNovel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsResearcher Researcher
 
KCD Costa Rica 2024 - Nephio para parvulitos
KCD Costa Rica 2024 - Nephio para parvulitosKCD Costa Rica 2024 - Nephio para parvulitos
KCD Costa Rica 2024 - Nephio para parvulitosVictor Morales
 
Levelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument methodLevelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument methodManicka Mamallan Andavar
 
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书rnrncn29
 
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork
 
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSneha Padhiar
 
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMSHigh Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMSsandhya757531
 
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptJohnWilliam111370
 
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTFUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTSneha Padhiar
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxsiddharthjain2303
 
OOP concepts -in-Python programming language
OOP concepts -in-Python programming languageOOP concepts -in-Python programming language
OOP concepts -in-Python programming languageSmritiSharma901052
 
Engineering Drawing section of solid
Engineering Drawing     section of solidEngineering Drawing     section of solid
Engineering Drawing section of solidnamansinghjarodiya
 
CS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfCS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfBalamuruganV28
 
Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdfCaalaaAbdulkerim
 
Cost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionCost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionSneha Padhiar
 
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Erbil Polytechnic University
 
Prach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism CommunityPrach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism Communityprachaibot
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating SystemRashmi Bhat
 
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.elesangwon
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 

Dernier (20)

Novel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsNovel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending Actuators
 
KCD Costa Rica 2024 - Nephio para parvulitos
KCD Costa Rica 2024 - Nephio para parvulitosKCD Costa Rica 2024 - Nephio para parvulitos
KCD Costa Rica 2024 - Nephio para parvulitos
 
Levelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument methodLevelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument method
 
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
 
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
 
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
 
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMSHigh Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
High Voltage Engineering- OVER VOLTAGES IN ELECTRICAL POWER SYSTEMS
 
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
 
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTFUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
 
Energy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptxEnergy Awareness training ppt for manufacturing process.pptx
Energy Awareness training ppt for manufacturing process.pptx
 
OOP concepts -in-Python programming language
OOP concepts -in-Python programming languageOOP concepts -in-Python programming language
OOP concepts -in-Python programming language
 
Engineering Drawing section of solid
Engineering Drawing     section of solidEngineering Drawing     section of solid
Engineering Drawing section of solid
 
CS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfCS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdf
 
Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdf
 
Cost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionCost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based question
 
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
 
Prach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism CommunityPrach: A Feature-Rich Platform Empowering the Autism Community
Prach: A Feature-Rich Platform Empowering the Autism Community
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating System
 
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 

Design Pattern - MVC, MVP and MVVM

  • 1. MVC, MVP and MVVM Design Patterns A comparison Mudasir Qazi - mudasirqazi00@gmail.com 111-Dec-14
  • 2. Contents / Agenda • Separation of Concerns • MVC • Definition and Architecture • Explanation of Modules • Sequence Diagram • Advantages and Disadvantages • MVP • Definition and Architecture • Explanation of Modules • Sequence Diagram • Advantages and Disadvantages • MVVM • Definition and Architecture • Explanation of Modules • Sequence Diagram • Advantages and Disadvantages • Summary (a comparison of all three patterns) • One Last Tip Mudasir Qazi - mudasirqazi00@gmail.com 211-Dec-14
  • 3. Separation of Concerns • All these methods do only one thing “Separation of Concerns” or “Layered Architecture” but in their own way. • All these concepts are pretty old, like idea of MVC was tossed in 1970s. • All these patterns forces a separation of concerns, it means domain model and controller logic are decoupled from user interface (view). As a result maintenance and testing of the application become simpler and easier. Mudasir Qazi - mudasirqazi00@gmail.com 311-Dec-14
  • 4. MVC Pattern Architecture • MVC stands for Model-View-Controller. Mudasir Qazi - mudasirqazi00@gmail.com 411-Dec-14
  • 5. Explanation of Modules Model: • The Model represents a set of classes that describe the business logic i.e. business model as well as data access operations i.e. data model. It also defines business rules for data means how the data can be changed and manipulated. View: • The View represents the UI components like CSS, jQuery, html etc. It is only responsible for displaying the data that is received from the controller as the result. This also transforms the model(s) into UI. Controller: • The Controller is responsible to process incoming requests. It receives input from users via the View, then process the user's data with the help of Model and passing the results back to the View. Typically, it acts as the coordinator between the View and the Model. There is One-to-Many relationship between Controller and View, means one controller can handle many views. Mudasir Qazi - mudasirqazi00@gmail.com 511-Dec-14
  • 6. Sequence Diagram Mudasir Qazi - mudasirqazi00@gmail.com 611-Dec-14
  • 7. Advantages of MVC • 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. • Since the Model is completely decoupled from view it allows lot of flexibilities to design and implement the model considering reusability and modularity. This model also can be extended for further distributed application. • It is possible to have development process in parallel for model, view and controller. • This makes the application extensible and scalable. • It is really effective with Microsoft’s ASP.Net and Entity Framework. Mudasir Qazi - mudasirqazi00@gmail.com 711-Dec-14
  • 8. Disadvantages of MVC • Requires high skilled experienced professionals who can identify the requirements in depth at the front before actual design. • It requires the significant amount of time to analyze and design. • This design approach is not suitable for smaller applications. • In case of complicated user interface with states of views related to each other and • Possible workflow models, this information though not business functionality related • Has to be in the Model layer. In very large systems this may be beneficial, otherwise it is usually transferred to the control layer, somewhat breaching the pattern. Mudasir Qazi - mudasirqazi00@gmail.com 811-Dec-14
  • 9. MVP Pattern Model-View-Presenter (MVP) is a variation of the Model-View- Controller (MVC) pattern but specifically geared towards a page event model. The primary differentiator of MVP is that the Presenter implements an Observer design of MVC but the basic ideas of MVC remain the same: the model stores the data, the view shows a representation of the model, and the presenter coordinates communications between the layers. Mudasir Qazi - mudasirqazi00@gmail.com 911-Dec-14
  • 10. MVP Pattern Architecture Mudasir Qazi - mudasirqazi00@gmail.com 1011-Dec-14
  • 11. Explanation of Modules Model: The model in MVP is just the same, that is described earlier in the Model-View- Controller pattern. Presenter: The Presenter’s responsibility is to handle user input and use this to manipulate the model data. The interactions of the User are first received by the view and then passed to the presenter for interpretation. Often, a presenter will maintain a selection that identifies a range of data in the model that is current, and the gestures received from the view will be used to act on this. There is One-to-One relationship between View and Presenter, means each view will be handled by one presenter. View: When the model is updated, the view also has to be updated to reflect the changes. View updates can be handled in several ways. Mudasir Qazi - mudasirqazi00@gmail.com 1111-Dec-14
  • 12. Passive view and Supervising Controller • The Model-View-Presenter variants, Passive View and Supervising Controller, specify different approaches to implementing view updates. • In Passive View, the presenter updates the view to reflect changes in the model. The interaction with the model is handled exclusively by the presenter. The view is not aware of changes in the model. • In Supervising Controller, the view interacts directly with the model to perform simple data-binding that can be defined declaratively, without presenter intervention. The presenter updates the model; it manipulates the state of the view only in cases where complex UI logic that cannot be specified declaratively is required. .NET Data-binding technologies make this approach more appealing for many cases, although if not carefully designed it may result in coupling between view and model. Mudasir Qazi - mudasirqazi00@gmail.com 1211-Dec-14
  • 13. Sequence Diagram for MVP Mudasir Qazi - mudasirqazi00@gmail.com 1311-Dec-14
  • 14. Advantages of MVP • As with Model-View-Controller, Model-View-Presenter has the advantage that it clarifies the structure of our user interface code and can make it easier to maintain. • Not only do we have our data taken out of the View and put into the Model, but also almost all complex screen logic will now reside in the Presenter. • We have almost no code in our View apart from screen drawing code Model- View-Presenter also makes it theoretically much easier to replace user interface components, whole screens, or even the whole user interface (Windows Forms to WPF for example). • This makes the user opinion sensitive UI part perfectly separate of other parts of the application, hence it’s features can be enhanced separately with more involvement from the customer. • In addition unit testing the user interface becomes much easier as we can test the logic by just testing the Presenter. Mudasir Qazi - mudasirqazi00@gmail.com 1411-Dec-14
  • 15. Disadvantages of MVP • Requires high skilled experienced professionals who can identify the requirements in depth at the front before actual design. • It requires the significant amount of time to analyze and design. • This design approach is not suitable for smaller applications. It overkills the small applications. • It can be hard to debug events being fired in active Model-View-Presenter. • The Passive View version of Model-View-Presenter can lead to a certain amount of boilerplate code having to be written to get the interface into the View to work. • In both MVP and MVC cases the code for supporting the proper pattern implementation can be complex, hence it is not advised to use in smaller projects. Mudasir Qazi - mudasirqazi00@gmail.com 1511-Dec-14
  • 16. MVVM Pattern • The Model-View-ViewModel (MVVM or ViewModel) is a pattern for separating concerns in technologies that use data-binding. • The first two pattern the MVC and MVP does not work as well as MVVM in declarative user interfaces like Windows Presentation Foundation or Silverlight because the XAML that these technologies use can define some of the interface between the input and the view (because data binding, triggers, and states can be declared in XAML). • The MVVM pattern is an adaptation of the MVC and MVP patterns in which the view model provides a data model and behavior to the view but allows the view to declaratively bind to the view model. Mudasir Qazi - mudasirqazi00@gmail.com 1611-Dec-14
  • 17. MVVM Architecture Mudasir Qazi - mudasirqazi00@gmail.com 1711-Dec-14
  • 18. MVVM Architecture Mudasir Qazi - mudasirqazi00@gmail.com 1811-Dec-14
  • 19. Explanation of Modules Model: The model is especially important because it wraps the access to the data, whether access is through a set of Web services, an ADO.NET Data Service, or some other form of data retrieval. The model is separated from the view model so that the view's data (the view model) can be tested in isolation from the actual data. View: The pattern we use is to set the Data Context of a view to its ViewModel. The view classes have no idea that the model classes exist, while the ViewModel and model are unaware of the view. In fact, the model is completely oblivious to the fact that the ViewModel and view exist. A View is the actual UI behind a view in the application. The elements of the UI are implemented in XAML, and as a result of this the code behind file contains minimal code, or in some cases it does not contain code at all, however it is different in Silverlight and WPF. Mudasir Qazi - mudasirqazi00@gmail.com 1911-Dec-14
  • 20. Continued… ViewModel: A ViewModel is a model for a view in the application as shown by its name. It has a collection which contain the data from the model currently needed for the view. Unlike the Presenter in MVP, a ViewModel does not need a reference to a view. The view binds to properties on a ViewModel, which, in turn, exposes data contained in model objects and other state specific to the view. The bindings between view and ViewModel are simple to construct because a ViewModel object is set as the Data Context of a view. If property values in the ViewModel change, those new values automatically propagate to the view via data binding. When the user clicks a button in the View, a command on the ViewModel executes to perform the requested action. The ViewModel, never the View, performs all modifications made to the model data. Mudasir Qazi - mudasirqazi00@gmail.com 2011-Dec-14
  • 21. Sequence Diagram for MVVM Mudasir Qazi - mudasirqazi00@gmail.com 2111-Dec-14
  • 22. Advantages of MVVM • Reduces the amount of code in the View’s code behind file. • UI elements can be written in XAML • Strong Data Binding, which saves a lot of code. No need for manually refresh the view. Mudasir Qazi - mudasirqazi00@gmail.com 2211-Dec-14
  • 23. Disadvantages of MVVM • In bigger cases, it can be hard to design the ViewModel up front in order to get the right amount of generality. • Data-binding for all its wonders is declarative and harder to debug than nice imperative stuff where you just set breakpoints. Mudasir Qazi - mudasirqazi00@gmail.com 2311-Dec-14
  • 24. Summary (1) Mudasir Qazi - mudasirqazi00@gmail.com 2411-Dec-14
  • 25. Summary (2) Mudasir Qazi - mudasirqazi00@gmail.com 2511-Dec-14
  • 26. Last Word • Must note the difference between the event responses of all patterns in Sequence diagram. It clears the confusion about the response of user input. Mudasir Qazi - mudasirqazi00@gmail.com 2611-Dec-14