What is MVVM? MVP? MVC?

ASP.NET MVC framework web application has three software architecture, such as MVC, MVVM, and MVP. Everyone’s software architecture has its features. Most people build the ASP.NET MVC web application projects, and then they don’t clearly know this project software architecture. They follow the Microsoft learning guide to create a web application project, an MVC architecture, because Microsoft’s official website provides more about the MVC learning guide. Still, the official website doesn’t tell the people other information about an other architecture of the ASP.NET MVC web application. Many enterprise IT team leaders, the programmer(PG), the system analytics(SA), the solution architect(SA), the software architect, the technology architect, and the system designer(SD) doesn’t understand where there is the difference and why Microsoft provides this guide for the beginner programmer and others.

WHY?

Before responding to this question answer, I will sort these software architectures by maintaining freedom, difficulty, and the software extension. After I write the answers, you will be easy to understand where there are differences. You will have the ASP.NET MVC framework learning map.

Maintain freedomDifficulty degreeExtension
MVCEasyMiddleGreat
MVVMMiddleEasyGreat
MVPDifficultDifficultDifficult
Table1

In the Table 1 table, you can find out the MVVM architecture is comfortable, superb extension, and the middle grade of the maintaining freedom, but you also can find the MVC architecture is better than the MVVM architecture at the maintain freedom part which is why Microsoft provides the MVC architecture guide to learn ASP.NET MVC web applications for the beginner and others.

In the recent few years, the MVC and MVVM are explicit in Microsoft’s developer world. All of the software architecture concepts are build by the N-layer architecture application knowledge. These layers include the User Interface(UI), the Business Logic Layer(BLL), and Data Access Layer(DAL). We can easily suppose all of the running logic in software architecture. First, the user makes the requests thoughts the UI layers, which interacts with the unique BLL layer that means the one-to-one mapping. Second, the BLL layers will return the DAL layers for the BLL layer’s data access request. DAL layer calls the SQL scripts, the store procedures, the SSIS package, or the SSRS. Finally, the web application will response the final data message on the client’s browsers. The top developer or the full senior software architecture will hope all of the objects are independent and reduce the coupling. They consider what kind of situation applies to web application architecture, consider the clean architecture principle and software design pattern concepts, then choosing the web application architecture road. Now I start to separate to introduction to everyone architectures.

Fig 1. Common web application layers

We quickly to review MVC basic components explanation, such as the model objects, the view objects, and the controller objects.

Model – It is the central component which is the application dynamic data structure, manages the data, the logic, the customized rule of the application.

Controller – It accepts the user requests or the program requests, then convert it to commands for the model or the view.

View – It response the information from the model or the controller, such as a chart, diagram, or table. Multiple views of the same information are possible from the system message management, a bar chart for management and so on.

MVC

MVC” or “Model-View-Controller,” as the name implies, has three objects. It is the basic pattern for the ASP.NET MVC web application projects that is the default projects in Visual Studio. These can let everyone object responsibility can clearly separates which ensure can’t modify or affect other objects. It also can increased the testability, the extension, the maintaining freedom, and non-couple ability.

Fig 2. MVC pattern

First described the Model-View-Controller(MVC) concepts by Glenn E. Krasner and Stephen T. Pope in 1988. MVC can explain that the client uses the controller component, then the controller component chooses the unique model to create data and then stores it to the data architecture. The model component updates the view component data. We can say the controller component is a communicator between the model component and the view component because the model component can’t directly influence interaction with the view component. MVC must ensure three parts which are independent of each other in ASP.NET web applications. The controller components management/controller ranges from the small class files to the enterprise services or extra system proxy services and the logic system. The view can use extra-methods to call the controller, for example, the AJAX method.

The MVC pattern has become the popular for the world wide web applications in the major programming languages now.

MVP

MVP” or “Model-View-Presenter” is the same as the MVC, which has three components, but it replaces the Controller(C) rules with the Presenter components, which means the middle-person. All of the logic writes on the presenter part. The View also is called “Passive View” or “View” in the MVP pattern. We can describe the client’s requests through the user events’ passive view components, interacting with presenter components. The presenter component calls the model components for the update model event and responds to the state-change events. The presenter component returns the update view event. It seems messy, so that we can sort out all of the expiation information below:

Model – It is an interface object which defines the data as a displayer or acted upon in the user interface object.

View – It is a passive view object that displays data or executes the user events by the route method.

Presenter – The middle rules grab the data from the repositories, then adapt the business logic and format or provide the business logic.

[MVP diagram without the user part]

Fig 3. MVP patterns

MVP pattern concept was the generation programming model for C++ and Java by Taligent in the 1990s. This pattern was based on the classic MVC programming model of Smalltalk. In 2006, Microsoft introduced the MVP into its documentation and the samples for user interface objects in the .Net Framework.

The MVP pattern is the user interface architectural designs, which adds the automatic unit test and improves the separation of concerns in the presentation logic parts. The MVP must follow the MVC pattern principle that ensures everyone components are independent, so it wants to reduce the coupling with the view components and the presenter components. The MVP pattern will use the inversion of control principle to increase the independent strength with each other. The programmer/developer will add the interface between the view component and the presenter component, then use the inversional control method to inject the presenter component. The presenter component will accord to the interface object’s method executes. The view component will accord to the interface object’s methods to display on the client’s browsers. We can find out the view components and the presenter components are limited by the interface objects, which can’t extend more function when the interface’s object doesn’t modify its.

MVVM

MVVM” or “Model-View-Viewmodel” seems like the MVP pattern, has the three components of the MVC. The ViewModel is the variation of Martin Fowler’s presenter model design pattern, which simplifies the user interfaces’ event-driven programming. The ViewModel replaces the controller part of the MVC pattern and is the contact person between the MVVM pattern’s view component and the MVVM pattern’s model component. For the first time, Microsoft uses these patterns that apply to the Windows Presentation Foundation (WPF, Microsoft’s .Net Graphics system) and Silverlight (WPF’s internet application derivative). It is also called the model-view-binder in the non-dot net platform, such as the ZK of the Java web application framework and KnockoutJS (Javascript Library).

Why the MVVM is explicit in the Microsoft world? “

In WPF developer age, the WPF of MVVM pattern provides the data binding function that can improve the view component with other components are independent. These patterns can vary through the view component to remove most of the GUI code. UX developers can 100% focus on the GUI code by the framework markup language(e.g., XAML), create the data binding of the view component, and maintain code. UX developer doesn’t need to know about the business logic part. This developed program process can increase the productivity of the program. The user interface will frequently need to modify, then closer the user experience. We can sort out all of the expiation information below:

Model – It represents the state’s real data, the data access layer, and the content data-centric approach.

View – It is responsible for layout, the structure, the char bar, and so on.

View Model – It is an abstraction of the view exposing public properties and command. It has the binder feature, which communicates view and bound properties. The binder is a markup language called XAML in the Microsoft solution.

Binder – Declarative data and the command-binding are implicit in the MVVM pattern.

[MVVM pattern diagram]

Fig 4. MVVM pattern

This pattern will close to the pure application for an advantage for binding data and framework. It also can gain the excellent benefit of the separation of function, which provides the MVC pattern.

John Gossman has criticized the MVVM pattern and its application in specific uses, stating that MVVM can be “overkill” when creating simple user interfaces. For larger applications, he believes that generalizing the viewmodel upfront can be difficult, and that large-scale data binding can lead to lower performance.From wiki

MVA

“MVA” or “Model-View-Adapter” or “mediating-controller MVC.” It is a new software architectural pattern in recent years. In my experience year, I don’t see and know which one enterprise uses this pattern. The MVA patterns are a complex application. Developers wish to separate the data, and the user interface, which means it doesn’t affect the data. They also hope the data doesn’t affect when the developer or UX developer has changed the user interface. This pattern is closer to the MVP pattern concepts. It adds the adapter components, which push the business logic. It lets the model and view doesn’t communicate. The view components must flow through the adapter components to choose the model components that means the view components deliberately forget the model component. The adapter components allow the same access models by the separation of concerns. Multiple adapters may be changed or created from one view for a given model. I believe the data message controller will provide the application of the MVP pattern more effect. Still, when we consider the hardware parts, I can ensure this pattern will need more memory to handle these message flow.

Fig 5. MVA pattern

Conclusion

We can know more software architectural pattern features, but we can’t only focus on a pattern. We must consider what kind of situation we should use what kind of software architectural pattern. Sometimes, we must add the hardware parts, the IT management policy, the financial budget, and tools. If you want to design a broad web application, I will recommend you choose the MVC pattern. If you’re going to use the XAML for the view components, I will recommend choosing the MVVM pattern. My advice isn’t always good to advise because I don’t know you encounter any situation. It would be best if you went cold down to consider more what is the thing which will affect your option about the source code growing future, and the source code maintains management.

Reference

Leave a Reply