在 MVC、MVP 和 MVVM 中,模型可以是实体的集合吗?

发布于 2024-12-29 05:08:44 字数 126 浏览 5 评论 0原文

我试图理解什么是模型。我已经阅读了这个答案

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

随风而去 2025-01-05 05:08:44

当然可以,我将模型视为用于渲染视图的属性的集合。不多也不少。如果您需要一组实体来呈现视图,那么它会很合适。

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.

栩栩如生 2025-01-05 05:08:44

绝对地。模型是描述业务逻辑使用的数据的全部内容。

然后,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.

夜巴黎 2025-01-05 05:08:44

在所有模式中,“模型”不是类或对象。模型是一个层 - 一种无形的结构,(在本例中)由几组结构组成。

模型的主要部分是:

  • 域对象(或者在某些地方称为:域实体、模型对象,业务对象)
  • 存储抽象
  • 服务(用于“应用程序逻辑” - 域对象和存储抽象之间的交互)

拥有多个“模型”是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:

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文