Possible Duplicate:
What is the difference between MVC and MVVM?
I am new in Asp.Net MVC pattern. I just have few questions related to MVC and MVVM
- What issues do these patterns address?
- How are they similar?
- How are they different?
Possible Duplicate:
What is the difference between MVC and MVVM?
I am new in Asp.Net MVC pattern. I just have few questions related to MVC and MVVM
Plenty of content out on the web covering this but as a starter this video will help you out
in ASP.NET MVC the request comes in from the web server and is handled directly by the Controller. The Controller determines the appropriate View and populates it with Models. The Controller then releases these instances to the underlying system which renders a result to the client. You can see that the Controller is first and last to act.
In MVVM, the UI (the View), faces the user and takes user input directly. Within the View, Commands within the ViewModel (which is the DataContext of the View) are triggered by this activity. Control flows to the ViewModel which interprets what the View has sent it and prepares its Models. After control flows back to the View it updates itself according to changes in the Models. If a new View is required, the ViewModel communicates this with the NavigationService (or whatever method of navigation your application uses), which is the purview of the Window or Frame--UI components. You can see that the ViewModel isn't first and last to act; the View plays a much greater role than in MVC.
As far as choosing which one is best, I would tend to be guided by tooling support. For instance, if you are using ASP.Net, there is a tremendous amount of automation through the MVC project template that helps with the boiler plate setup and use of that pattern in an application. From what I understand about Silverlight/WPF, there is a lot of support there around MVVM. When I was coming up to speed on MVC/MVP a few years ago, I implemented MVP in the checkout process of an eCommerce application. It was a great experience with a satisfying outcome, but I was writing everything by hand with no tooling support and little guidance. When I write a Silverlight app, I will certainly be moved toward MVVM because of the support that is there.
MVC is a software architectural pattern that allows you great seperation especially that of domain logic, user interface, business logic etc and allows for a total seperation of concerns and allows for independent logics to be developed seperately and tested seperately as well as ease of testing multiple versions of implementations without much ado.
Model is if you like the entity that describes everything that you want to capture including its behaviour although most people think of it in terms of a database table, but its merely a storage model and model combines everything.
View is if you like the UI that you interact with
Controller is the one that drives the interaction between View making or taking changes that happen on model.
MVVM if you like is same as MVC but it uses an extra View Model to help with the UI and this View Model sync with the model via controller.
The architecture that also encompases best practices like repository pattern, IOC etc.
A quick e.g. of say a person model
Now a View model that will help with the UI may have a dropdownlist to poplulate types of persons so a ViewModel for same model may be
This may than be used in view as //PseudoCode Dropdownlist(slectList)
Hope this helps