1

I try to understand what a Model is. I already read this answer.

In MVC, MVP and MVVM the model could it be a collection of entities?

Community
  • 1
  • 1
Bastien Vandamme
  • 17,659
  • 30
  • 118
  • 200

3 Answers3

1

Sure it could, I think of a model as a collection of properties that are used to render a view. No more, no less. If you need a collection of entities to render the view then it would be appropriate.

Jason
  • 15,915
  • 3
  • 48
  • 72
0

In all of the patterns "Model" is not a class or object. Model is a layer - an intangible construction, which (in this particular case) consists several groups of structures.

The main parts of model are:

  • domain objects (or in some places called: domain entities, model objects, business objects)
  • storage abstractions
  • services (for "application logic" - interaction between domain objects and storage abstractions)

Having multiple "models" is a misconception that was introduced by Rails (rapid prototyping framework for ruby), which, for sake of some simplification, decided to call their active record instances "models" and refer to their templates as "views".

tereško
  • 58,060
  • 25
  • 98
  • 150
0

Absolutely. A Model is all what describes a data used by business logic.

Ofthen in MVVM Model is encapsulated by the appropriate ViewModel itself. You need to separate a Model layer from ViewModel in case when different models could be handled by a single ViewModel.

sll
  • 61,540
  • 22
  • 104
  • 156
  • -1: no, model is a layer that contains all of the business logic. Model is **not** data. – tereško Aug 01 '13 at 14:46
  • @tereško: thanks for your comment. I would say it depends, in MVVM model sometimes is not introduced at all so ViewModel represents both logic and model – sll Aug 01 '13 at 15:06
  • Which interpretation of "viewmodel"? Originally the pattern was used for cases when you either have no control over implementation of model (think, some SAP backend system) or/and view. And the viewmodel was in the place of controller, where it was responsible for translating data from one to other. The **other** one is the ASP.NET MVC (mis)interpretation, where they took [presentation object](http://martinfowler.com/eaaDev/PresentationModel.html) concept (Fowler has this annothing habit of adding "model" to everything) and called it "viewmodel". – tereško Aug 01 '13 at 15:22