Skip to main content

MVC - Introduction




What is MVC?

Model-View-Controller (MVC) has been an important architectural pattern in computer science for
many years.It was originally named Thing-Model-View-Editor in 1979, it was later simplifi ed to Model-View-Controller.Although originally developed for desktop computing, model–view–controller has been widely adopted as an architecture for World Wide Web applications in major programming languages.

Difference between MVC, MVP and MVVM


MVC

The input is directed at the Controller first, not the view.

That input might be coming from a user interacting with a page, but it could also be from simply entering a specific url into a browser. In either case, its a Controller that is interfaced with to kick off some functionality.
There is a many-to-one relationship between the Controller and the View. That’s because a single controller may select different views to be rendered based on the operation being executed.
Note the one way arrow from Controller to View. This is because the View doesn’t have any knowledge of or reference to the controller.
The Controller does pass back the Model, so there is knowledge between the View and the expected Model being passed into it, but not the Controller serving it up.


MVP

The input begins with the View, not the Presenter.

There is a one-to-one mapping between the View and the associated Presenter.
The View holds a reference to the Presenter. The Presenter is also reacting to events being triggered from the View, so its aware of the View its associated with.
The Presenter updates the View based on the requested actions it performs on the Model, but the View is not Model aware.



MVVM

The input begins with the View, not the View Model.

While the View holds a reference to the View Model, the View Model has no information about the View. This is why its possible to have a one-to-many mapping between various Views and one View Model…even across technologies. For example, a WPF View and a Silverlight View *could* share the same View Model. However, my own feeling is that this is a bad practice and creates Franken-ViewModels that have too many responsibilities. It’s better to keep it as a one-to-one mapping instead.
You’ll also notice that the View has no idea about the Model in the MVVM pattern. This is because, as far as the View knows, its “Model” IS the View Model (hence its name). Because of how data-binding and other features like commanding work in WPF and Silverlight, there is rich communication between the View and View Model, isolating the View from having to know anything about what’s really happening behind the scenes.



Comments

Popular posts from this blog

C# - Decision Making

  <<PreviousPage     NextPage>> Decision Making If Else Statement If Else statement is used for decision making in c# . In the below example we will see how we can use if else statement in C# to great effect.   Nested If Else Statement We can improve upon the above example by adding nest if else statement. Nested if else statement helps to add extra if else block with in an if or else block. Switch Statement In place where we need multiple if else statements to satisfy a criteria we can add switch statement instead of if else statement.  We can create an application which would answer our question and let us know about the Date and Time. This will be a small AI sort of idea which would recognize your command and perform accordingly.  Code -    Console.WriteLine("................Welcome to Mini AI................");            str...

C# - Data Type Conversion

  <<PreviousPage      NextPage>> Data Type Conversion  In our previous tutorial we have seen various types of data and how to use them. In this session we are going to look into how to convert these data type from one to another.  Implicit Conversions In Implicit conversion can be made when the value to be stored can fit into the variable without being truncated or rounded off. We can take example of int and long, float and double. we can declare a variable int and assign it to a long type which is an implicit conversion as the scope of long is bigger than that of int so there is no worry of loosing data.  Explicit Conversions However, if a conversion cannot be made without a risk of losing information, the compiler requires that you perform an explicit conversion, which is called a cast. A cast is a way of explicitly informing the compiler that you intend to make the conversion and that you are aware ...