Two questions about MVC: 1) What is difference between .net MVC and Android MVC? 2) Why need to use ViewModels in MVC?
I would appreciate if anyone can answer these questions.
Two questions about MVC: 1) What is difference between .net MVC and Android MVC? 2) Why need to use ViewModels in MVC?
I would appreciate if anyone can answer these questions.
Model-View-Controller
In the MVC, the Controller is responsible for determining which View is displayed in response to any action including when the application loads. This differs from MVP where actions route through the View to the Presenter. In MVC, every action in the View correlates with a call to a Controller along with an action. In the web each action involves a call to a URL on the other side of which there is a Controller who responds. Once that Controller has completed its processing, it will return the correct View. The sequence continues in that manner throughout the life of the application:
Action in the View
-> Call to Controller
-> Controller Logic
-> Controller returns the View.
One other big difference about MVC is that the View does not directly bind to the Model. The view simply renders, and is completely stateless. In implementations of MVC the View usually will not have any logic in the code behind. This is contrary to MVP where it is absolutely necessary as if the View does not delegate to the Presenter, it will never get called.
MVC is a concept rather than a solid programming framework. You can implement your own MVC in any platforms.
Model: What to render
View: How to render
Controller: Events, user input
Question 1: Android MVC and .Net MVC
Android MVC:
In Android you don't have MVC, but you have the following:
More Ref : MVC pattern on Android
.net MVC :
ASP.Net MVC is an open source web application framework that implements the model–view–controller (MVC) pattern.
More Ref : http://en.wikipedia.org/wiki/ASP.NET_MVC_Framework
Question 2: Why need to use ViewModels in MVC?
ViewModel help us to organize and manage data in a strongly-typed view with more flexible way than complex objects like models or ViewBag/ViewData objects.It allow you to shape multiple entities from one or more data models or sources into a single object, optimized for consumption and rendering by the view.
More Ref: http://rachelappel.com/use-viewmodels-to-manage-data-amp-organize-code-in-asp.net-mvc-applications