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

▼魔方 西西 提交于 2019-12-23 00:41:42

问题


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?


回答1:


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.




回答2:


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.




回答3:


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".



来源:https://stackoverflow.com/questions/9031916/in-mvc-mvp-and-mvvm-the-model-could-it-be-a-collection-of-entities

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!