MVC:有人知道 MVC 的多视图设计吗?

发布于 2024-08-08 08:42:34 字数 506 浏览 7 评论 0原文

我有一个系统需要同一模型的两种表示, 为简单起见,我想使用一个模型,而不是保留多个模型 - 因为我的系统会出现翻译错误(模型不兼容),这可能会导致系统出现故障。

有谁知道解决该问题的良好设计实践?

例如,假设我有 UserList 其中包含多个用户。 一方面,我想查看我的所有用户列表和用户 它们每个都包含。从另一个 我想知道每个用户的手 这是他的用户列表 属于. 我可以保存此信息两次(一次从用户列表的角度 一旦从用户角度 查看..)但这听起来不像 一个很好的做法。 更进一步,假设用户列表有一些属性可以 通过系统视图进行配置 模型。 我如何让模型的用户视图知道有一个 其中之一的配置更改 属性(无需扔掉 用户列表并告诉每个用户是什么 变化,或者是否有 改变)。

如何同时维护同一个模型的多个视图——系统视图和用户视图,同时防止数据和信息的重复,并方便查询模型信息及其变化?

I have a system that need two representations of the same model,
and for simplicity i want to use one model, and not keep multiple models - because than my system will suffer from translation errors (the models will not be compatible) that might cause the system to be faulty.

Does anyone know a good design practice for that problem?

For example lets say i have UserList
which contains multiple users.
From one hand i want to see the all of my userlists and the users that
each of them contains. From the other
hand i want to know for each user
which are the userlists that he
belongs to.
I can save this information twice (once from the userlist point of view
and once from the user point of
view..) but that doesn't sounds like
a good practice.
Further more, let's say that the userlist has some properties that can
be configured by the system view of
the model.
How do i let the user view of the model know that there was a
configuration change in one of the
properties (without going threw the
userlist and tell each user what was
the change,or whether there was a
change).

How do i maintain these multiple views of the same model - the system view, and the user view in the same time while prevent the duplication of data and information and the ease of query for the model information and changes in it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

清旖 2024-08-15 08:42:34

继续 http://martinfowler.com/eaaDev/index.html

:正确的可以访问许多表示模式,并解释所有内容。


或者,如果您使用 java/Swing,每个模型都可以轻松地由多个视图使用,因此您只需遵循常规流程...:-)

Go on http://martinfowler.com/eaaDev/index.html :

The list on the right gives access to many Presentation Patterns, with everything explained.


Alternatively, if you use java/Swing, each model can easily be used by several views, so you just follow the regular flow... :-)

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