Why is MODEL in ASP.NET MVC sometimes used as part of an application that talks to a database like here and sometimes as a business object that "travels" across applications delivering data like here?
Model. The model is the M in MVC. The data model represents the core information that your application is being used to access and manipulate. The model is the center of your application, the viewer and controller serve to connect the user with the data model in a friendly way.
The model layer is responsible for the business logic of the application. It manages the application state. This also includes reading and writing data, persisting application state, and it may even include tasks related to data management, such as networking and data validation.
The Model layer represents the part of your application that implements the business logic. It is responsible for retrieving data and converting it into meaningful concepts for your application. This includes processing, validating, associating or other tasks related to handling data.
In MVC M stands for Model and Model is a normal C# class. Model is responsible for handling data and business logic. A model represents the shape of the data. Model is responsible for handling database related changes.
MVC has evolved in different directions since its Smalltalk beginnings to the point where it is often used to describe very disparate architectures, as you've discovered.
Martin Fowler blogs about the evolution of MVC here. http://martinfowler.com/eaaDev/uiArchs.html
There is an explanation of the differences between MVC, MVP and MVVM here: http://joel.inpointform.net/software-development/mvvm-vs-mvp-vs-mvc-the-differences-explained/
My 10c:
Many examples of ASP.NET MVC 3 are more closely aligned to the MVVM pattern than MVC. In MVVM, ViewModels are tailored for the data specifics of each View (i.e. 'ViewModels' are not merely domain models, but are decorated with View / Presentation Tier concerns such as validation rules, field prompts / names, field visibility etc).
(Back to MVC) In smaller data centric projects without much need for back end tiering, M can be as simple as an ORM model (e.g. an .EDMX with some autogenerated POCOs) with a few rules. In this case MVC could just about be regarded as an application architecture.
But in larger projects using MVC, the original (Smalltalk) 'M' of model is now split up into several other layers, e.g. domain entities, service facades, Service (e.g. SOA), Business, and Data Tiers, etc (so here, M VC is a presentation tier pattern, and M is the rest of your system). So for example in such a project, the 'Models' folder of your MVC project could simply be proxied service references and proxied domain entities used to communicate with the 'back end' of your system, or even an abstraction of this communication (e.g. see the service agent / service facades used in the Composite Application Block).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With