在 MVC、MVP 和 MVVM 中,模型可以是实体的集合吗?
我试图理解什么是模型。我已经阅读了这个答案。
在 MVC、MVP 和 MVVM 中,模型可以是实体的集合吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当然可以,我将模型视为用于渲染视图的属性的集合。不多也不少。如果您需要一组实体来呈现视图,那么它会很合适。
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.
绝对地。模型是描述业务逻辑使用的数据的全部内容。
然后,MVVM 中的模型通常由适当的 ViewModel 本身封装。您需要将模型层与 ViewModel 分开,以防单个 ViewModel 可以处理不同的模型。
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.
在所有模式中,“模型”不是类或对象。模型是一个层 - 一种无形的结构,(在本例中)由几组结构组成。
模型的主要部分是:
拥有多个“模型”是Rails(Ruby的快速原型框架)引入的一个误解,为了简化,决定将其活动记录实例称为“模型”,并将其模板称为“视图”。
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:
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".