Before understanding the differences, let's look at how the design patterns work and make better use of one of the two (MVC design and MVP. The (MVC design and MVP) model has been used for several years. A key problem to be solved is the main focus of object-oriented, separated user interfaces and business layers.
There are also some frameworks based on which Java struts, Ror, Microsoft Smart Client software factory (CAB), Microsoft Web client software factory,
And recently announced ASP. net mvc Framework. framework.
Model View Controller (MVC design) Mode
The MVC mode is a user interface demonstration mode, focusing on the user interface (View) separated from the business layer (model ). This mode consists of three parts: view is responsible for rendering UI elements, controller Controller is responsible for responding to user interface actions,
This model is responsible for business behavior and status management. In most executions, all three components can communicate with each other directly. In some implementation controllers, the view display (Front Controller pattern) is determined ),
Model considers the host (MVP) Mode
The (MVP) mode is a conceptual MVC mode based on the MVC mode. Mode responsibilities are divided into four parts: view is responsible for rendering the UI elements, interface is used to solve Niu control it (presenter) host, presenter master
Interface interfaces and service layers are usually used to simplify unit tests in presenter and model modes.
Main advantages
When using any model, developers need to consider the advantages and disadvantages before using it. There are some key advantages that can be decided to use the MVP or MVC mode (see the list below ).
However, a few people have requested their support. The biggest drawback is the extra complexity and learning curve. Although the mode may not be suitable for a simple solution, the solution can greatly benefit from the use mode.
My experience is that I have used several mode solutions, which eliminate a lot of complexity, but I am rethinking the better use mode.
Loose coupling-presenter/controller plays the intermediary role between the user interface code and the model. This makes the interface and model independent.
Clarify separate problems/responsibilities
1. view User Interface (Form or page)-responsible for rendering u I Elements
2. presenter/controller host-responsible for handling u I element events and user interface and model interaction
3. Model-responsible for business behavior and status management
Test driver-isolating each major component (user interface, demo/controller and model) is easier to write unit tests. Especially when the MVP mode is used, this is why presenter only communicates with the view interface through the interface.
Concerns/responsible
Code reuse-by using a caring or responsible design method, code reuse is increased. Especially when a domain model is used and all business/State management logic is maintained.
Hide data access-using these modes forces you to encapsulate data access code in a data access layer. There are other typical modes, such as data access with MVP/MVC. Two of the most common ones are repository and unit of work. (See Martin Fowler-patterns of enterprise application architecture for more details)
Flexibility/Adaptability-by isolating most of the Code to the host/controller and model composition code to better adapt to changes. For example, considering how many UIS and data access technologies have changed over the years and the number of options available today. An appropriate design solution or mvc mvp can support multiple user interfaces and one data synchronization.
Main differences
So, the true difference between MVP and MVC models. In fact, there are not many differences. The two models focus on separating responsibilities across multiple components and promoting loose coupling of user interfaces (Views) from the business layer (models ). The main difference is how to implement the model and some advanced scenarios you both need to host and controller.
Here is the key mode of divergence:
1 view and model are more loosely coupled. The presenter is responsible for binding the model and view.
The presenter is responsible for binding the model to the view.
2. Easy unit test, because the interaction with view is through an interface
3. Generally, presenters correspond to views one by one. Complex views may contain multiple presenters.
MVC Mode
1. The controller is behavior-based and shareable views.
2 can be responsible for determining which view to display (Front Controller pattern)
I hope you will be interested in this article and it will help clarify the differences between them and the MVP MVC pattern. If this is not the case, even if the mode is a powerful tool, it is difficult to use sometimes.
One thing to remember is that a model is a blueprint, rather than a complete solution. Developers should use them for guidance and modification based on their issue domains.