ASP.Net MVC and MVVM

MVVM is a Microsoft design pattern that existed before ASP.Net MVC. Can someone highlight the differences between MVVM and the new MVC pattern ?.

+7
model-view-controller mvvm
source share
4 answers

Can we shed light on the differences between MVVM and the new MVC pattern ?.

Yes. When using ASP.NET MVC, the MVC pattern uses a controller to render the model directly in the view. This is quite acceptable for trivial projects with a small number of objects. Where this can become a problem, the problem is that user interface level problems can go through the base (domain) model.

When using MVVM, you add an abstraction between the model and the view, which of course is the ViewModel. This allows the author to design in the view the object that is most easily absorbed by the view. ViewModel may contain things that would be inappropriate in the (domain) model. The cost associated with this is that you need to have cartographic logic that transfers data from the model to the View Model. Tools like AutoMapper can help with this job.

A simple example of this may be a model that does not require specific fields as necessary, but does a specific view. Instead of baking this logic in the user interface, if it is connected to the ViewModel, then another user interface can use the same virtual machine without the need to duplicate the logic that was baked in the first user interface.

+13
source share

MVC and MVVM are actually quite different. It looks like there was a misunderstanding with MVCM in ASP MVC. The practice of creating "View Models" in MVC, which are specific classes for presenting views, while good practice does not conform to the spirit of MVVM and is actually just a cleaner version of MVC.

MVVM is more suitable for desktop using WPF or similar, or simply in a browser using a JavaScript framework such as knockout.js. The template is different from MVC and includes views, "subscribed" to the model.

+4
source share

I would venture to suggest that MVVM is Microsoft's design pattern, and ASP.NET MVC, which is the latter, is a specific implementation of Microsoft (which does not necessarily correspond to MVC or MVVM, but is similar). And, as Reed suggested, MVC has existed since the 70s.

+2
source share

Both MVC and MVVM are architectural patterns. MVC is rooted in Smalltalk. ASP.NET MVC is a Microsoft implementation of the MVC pattern using the ASP.NET framework.

Both patterns relate to separation of concerns. MVC is more concerned with the interaction of various commonly used layers in an application, such as Model (data layer), View (presentation layer) and Controller (business logic layer).

With advanced WPF and Silverlight data binding capabilities, MVVM is more suitable and advertised as the next big thing. Martin Fowler summarized these patterns as presentation patterns in his book Enterprise Application Architecture.

One of the advantages that I see when using ViewModel is that it allows you to better test application code using unit tests. For this reason, I find MVVM, or at least the ViewModel bit, which it uses quite often in ASP.NET MVC applications.

+1
source share

All Articles