Translate an article on CodeProject, describe and compare several common expressions (Presentation patterns. The original address is http://www.codeproject.com/KB/aspnet/ArchitectureComparison.aspx
Presentation patterns background
The biggest problem related to the User Interface (UI) is a large amount of messy code, mainly caused by these two factors, first, the user interface contains the responsible logic for maintaining interface-related objects, and second, the application state maintenance. Presentation patterns is generated by removing the complexity of the user interface and making the interface more concise and manageable. It is the types and categories of common Presentation modes:
Three major issues on the user interface: State, Logic, and Synchronization)
- Status ):Status is one of the most important issues on the user interface. The status is the current snapshot of user interface data. In a Web application, it may be a Session-level variable. In a Windows application, it may only be interface-level data. The more states a user interface contains, the more complex the user interface is.
- Logic ):A user interface usually contains interface logic, such as maintaining a text box, a combo box, or any other interface element. The more logic a user interface has, the more complicated the user interface is.
- Synchronization (Synchronization ):The User Interface usually needs to work with business components. Therefore, the user interface needs to synchronize data between interface elements and Business Objects. If the user interface contains more synchronization tasks, the more complex the user interface is.
The relationships between these three problems and the user interface are as follows:
Presentation Design Pattern)
The presentation design pattern helps solve the problems listed above. Its basic logic is to create an additional presentation class (Presenter) to digest the complex logic, data, and synchronization issues on the user interface, this makes the user interface simple and clear. Depending on the number of responsibilities of this class, it determines the type of the presentation design model, which may be SC, PV, PM, etc. That is to say, the maturity of this class determines that it will be the design model.
Abbreviations
Abbreviations |
Complete Form |
V |
View or UI) |
P |
Presenter class which has the UI logic .) |
L |
User interface logic |
S |
User Interface status |
M |
Business component or Business Object |
SC |
Supervising controller) |
PV |
Passive view) |
PM |
Passive view) |
Monitoring controller mode (SC)
- Save status in view
- The presentation class has complex presentation logic. It only focuses on simple interface binding logic, such as the binding mechanism provided by WPF or Silverlight (Presenter owns the complex presentation logic. simple UI binding logic is taken care by using binding technologies like WPF binding and Silverlight binding. anything complex is taken care presenter class .)
- Display class focus View
- View does not focus on performance
- The view is associated with the business model through data binding
Passive view mode (PV)
- Save status in view
- All interface logic is included in the presentation class.
- The view and business model are completely independent. In this case, you need to synchronize data between the business model and the view.
- Display class focus View
- View does not focus on performance
Presentation Model (PM)
- Presentation class inclusion Logic
- Presentation class inclusion status
- The presentation class represents an abstract user interface.
- The presentation class does not focus on the user interface
- View focus class
- The view is completely isolated from the business model.
MVVM
- Inherited self-representation model
- Use the binding mechanism of WPF and Silverlight
MVC
- No presentation class, Controller)
- The request first arrives at the Controller
- The Controller is responsible for binding views and business models
- The logic exists in the controller.
Summary and Comparison
The following table compares the status, logic, and synchronization modes.
|
|
Status |
Logic |
Synchronization |
Supervising controller |
|
|
|
|
|
Presentation class |
|
X |
X |
|
View |
X |
|
|
|
Business Model |
The view and business model are connected by binding. |
Passive View |
|
|
|
|
|
Presentation class |
|
X |
X |
|
View |
X |
|
|
Presenter model |
|
|
|
|
|
Presentation class |
X |
X |
|
|
View |
|
|
X |
MVVM |
|
|
|
|
|
Presentation class |
X |
X |
|
|
View |
|
|
X |
|
Use the Data Binding Mechanism of WPF and Silverlight |
MVC |
|
|
|
|
|
Controller |
|
X |
X |
|
View |
X |
|
|
Comparison of another Graph