仅针对 GUI 查看模型?
我在开发 GUI 组件时一直在研究 ViewModel 概念。 我喜欢 ViewModel 是完整模型的子集的想法, 我可以对模型有不同的看法。 (并且 ViewModel 独立于实际的 GUI 视图!)
然后我开始考虑是否也可以将这个概念用于非 GUI 模块。 例如,集成组件也可能需要模型的子集,并且可能 具有抽象意义上的“绑定”和“事件”。
那么,对于 ViewModel 的抽象意义,有什么想法,不局限于 GUI 吗? 或者我误解了 ViewModel 的概念? :-)
感谢您的任何反馈!
I've been looking at the ViewModel concept while working on a GUI component.
I like the idea that a ViewModel is kind of a subset of the complete Model,
and that I can have different views into the Model.
(And that the ViewModels are independent of the actual GUI View!)
Then I started thinking about if I could use the concept also for non-GUI modules.
For example, integration components also may need a subset of the Model, and may
have "bindings" and "events" in an abstract sense.
So, are there any thoughts about the abstract sense of ViewModels, not being limited to GUI?
Or have I misunderstood the ViewModel concept? :-)
Thanks for any feedback!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ViewModel 当然可以应用于非 GUI 工作,尽管在该设置中它最终可能会具有不同的名称。查看PAC,了解非 GUI 设置中的 MVC 扩展。
ViewModel certainly could be applied to non-GUI work, though it might end up with a different name in that setting. Have a look at PAC for an extension of MVC in non-GUI settings.
例如,在使用 Web 服务时,ViewModel 通常称为“数据传输对象”。
听起来更像是你想使用接口。
ViewModels are usually called Data Transfer Objects when working with web services for instance.
Sounds more like you want to use interfaces.