数据绑定从根本上与MVC不兼容吗? [英] Is data binding fundamentally incompatible with MVC?

查看:56
本文介绍了数据绑定从根本上与MVC不兼容吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

数据绑定在视图和模型之间建立直接耦合,从而绕过了控制器.从根本上讲,这与Model-View Controller的架构模式不符,我是否正确地考虑了这一点?这会使数据绑定成为坏事"吗?

Data binding establishes a direct coupling between the view and the model, thereby bypassing the controller. Fundamentally this breaks with the Model-View Controller architectural pattern, am I right in thinking this? Does this make data binding a "bad thing"?

编辑:例如, angular 声称是MVC框架,但还是其中之一它的主要功能是数据绑定.

As example, angular claims to be a MVC framework, yet one of its main features is data binding.

推荐答案

不一定,因为您不必将Model对象绑定到视图.
我通常要做的是创建简单的DTO(或演示对象),这些DTO仅包含我要显示的数据,这就是View层显示的内容.
在那种情况下,控制器保留其在DTO上执行的操作与基础Model实体上的操作之间的翻译器功能.

Not necessarily, since you don't have to bind your Model objects to the view.
What I usually do is create simple DTOs (or Presentation Objects) that contain only the data I want to display, and that's what the View layer displays.
In that case, the Controller retains its function as a translator between actions performed on the DTOs and actions on the underlying Model entities.

这篇关于数据绑定从根本上与MVC不兼容吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆