Comparison of Architec…
来源:互联网 发布:电脑麦克风软件 编辑:程序博客网 时间:2024/04/30 21:41
Introduction
This article will compare four important architecture presentationpatterns i.e. MVP(SC),MVP(PV),PM,MVVM and MVC. Many developers areconfused around what is the difference between these patterns andwhen should we use what. This article will first kick start with abackground and explain different types of presentation patterns. Wewill then move ahead discussing about the state , logic andsynchronization issues. Finally we will go in detail of eachpattern and conclude how they differ from each other.
Here’s my small gift for all my .NET friends , a complete 400 pagesFAQ Ebook which covers various .NET technologies like Azure , WCF ,WWF , Silverlight , WPF , SharePoint and lot morefrom
Background- Presentation patterns
One of the biggest problems associated with user interface is lotof cluttered code. This cluttered code is due to two primaryreasons , first the UI has complicated logic to manipulate the userinterface objects and second it also maintains state of theapplication. Presentation patterns revolve around how to remove theUI complication and make the UI more clean and manageable. Beloware different variety and classifications of presentation patternsas shown in the below figure.
Presentation pattern are divided in to three important categoriesMVP ( Model view presenter ) , MVC ( Model view controller) andfinally (PM) presenter model. MVP is further divided in tosupervising controller and passive view. Presenter model is furtherdivided by Microsoft team in two technology specific patterns MVVMfor silverlight and MVVM for WPF.
3 big problems of UI :- State , Logic and Synchronization
There are 3 big problems associated with UI as listed below.
State
Logic
Synchronization
The Hero - Presentation design Pattern
Presentation design pattern helps to solve the above UI problems.The base logic of presentation design patterns is that we need tocreate a extra class which will consume complicated logic , dataand synch issues which currently the UI does , thus making the UIdump , clean and simple. Depending on how much this class takesresponsibilities defines further whether its a SC , PV , PM designpattern etc. In other words its the maturity of the presenter classwhich will define what kind of design pattern it is.
Some acronyms to simplify the article
AcronymFullformVView or user Interface.PPresenter class which has the UI logic.LUI logicSState of the UIMBusiness components or domain objects.SCSupervising controller .PVPassive view.PMPresenter model.
We will use the above acronym to simplify our explanation ofpresentation design pattern.
Supervising controller pattern ( SC )
Fundamentals about SC :-
- State is stored in the view.
- Presenter owns the complex presentation logic. Simple UI bindinglogic is taken care by using binding technologies like WPF bindingand Silverlight binding. Anything complex is taken care presenterclass.
- Presenter is aware of the view.
- View is not aware of the presenter.
- View connects with model using technical bindings provided by WPFand Silverlight.
Passive view (PV)
Fundamentals about PV :-
- State is stored in the view.
- All logic of UI is stored in presenter.
- View is completely isolated from the model. It also takes the extratask of synchronizing data between model and view.
- Presenter is aware of the view.
- View is not aware of the presenter.
You can read more about MVP (PV) from this , it also has a samplecode which shows how MVP comes in toaction
Presentation Model (PM)
Fundamentals about SC :-
- State is stored in the presenter.
- Logic is stored in presenter.
- Presenter represents a abstract view of the UI.
- Presenter is not aware of the view.
- View is aware of the presenter.
- View is completely isolated from the model.
MVVM
Fundamentals about SC :-
- Presenter model is the base.
- State is stored in the presenter.
- Logic is stored in presenter.
- Presenter represents an abstract view of the UI.
- Presenter is not aware of the view.
- View is aware of the presenter.
- View is completely isolated from the model.
- Uses WPF and Silverlight bindings.
MVC
Fundamentals about MVC :-
- Does not have a presenter , has a controller.
- Request first comes to the controller.
- Controller binds the model with the view.
- Logic is stored in the controller.
You can read more about MVC from this, it also has a sample codewhich shows how MVC comes in to action
Summarizing
Below is a summary comparison table for all presentation patternsfrom the aspect of state , logic and synchronization.
Below is a visual comparison of what we discussed above.
When to use MVP and When to use MVC ?
First thing all the above patterns are variations of MVC. In otherwords all MVP patterns are twists of MVC. We will compare betweenMVC and MVP first and then we will compare between differentvariations of the MVP.
Below are the situations of when MVP is preferred over MVC.
UI unittest :-
Views aresame with slight variations
Multi UIsupport
ComplexScreens
Technologyused
Technology selection drives 60% of whether you will select MVC orMVP.
- Comparison of Architec…
- Oracle Optimal Flexible Architec…
- resource is out of sync with t…
- identifier of an …
- failure of the “Grid Installatio…
- Solution of Enable extension for…
- Filtering of Hierarchical Data i…
- Journal of Machine Learning Rese…
- To add a multiplexed copy of the…
- ZOJ 1504(POJ 1244) Slots of Fun…
- hdu 1692 Destroy the Well of Lif…
- Lesson 47 A cup of coffee 一杯咖…
- Picture of my baby when 2 monthe…
- To represent Asia - the issue of…
- I am the captain of my sou…
- poj 3083 Children of the Candy C…
- object is not an instance of dec…
- What are the meaning of the code…
- android 生命周期
- Android应用程序的生命周期
- 深入浅出 iOS 之生命周期
- ios的生命周期
- makefile
- Comparison of Architec…
- Java_全面总结Java泛型
- Java_泛型的理解与等价实现
- HDU 1179 Ollivanders: Makers of Fine Wands since 382 BC. 最大匹配
- Java_List对象排序通用方法
- Java_int 和integer的区别
- Java_Object的使用
- Java_instanceOf
- java_instanceOf关键字