表示层对象

发布于 2024-07-20 17:41:54 字数 40 浏览 3 评论 0原文

表示层是否应该分为呈现对象和接收对象,还是双向处理数据的单个对象?

Should a Presentation Layer be split into presenting and receiving objects Or single objects that handle data in both directions?

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

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

发布评论

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

评论(1

往日情怀 2024-07-27 17:41:54

表示层应该位于处理呈现和接收的接口后面。 主要原因是,如果您有两个接口,一个用于呈现,另一个用于接收,理论上可能会分配给每个接口两个不同的对象,从而导致测试中出现奇怪的情况。

但是,如果您的界面正在开发成数十种方法,您可能需要退后一步,考虑将其划分为更小的单元,然后将它们聚合起来。 不一定基于接收和呈现,而是基于呈现 UI 的更逻辑划分。

例如,您可以有一个包含两个变量的 IPresentationUI,一个是 IPresentationDisplay 的接口,另一个是 IPresentationControl 的接口。 您拥有的唯一注册例程将接受 IPresentationUI 对象。 实现演示层的类将实现三个接口 IPresentationUI、IPresentationControl 和 IPresentationDisplay。

The presentation layer should be sitting behind interfaces that handle both presenting and receiving. The main reason is that if you had two interfaces, one for presenting and the other receiving it is possible, in theory to wind up with two different object assigned to each causing strangeness in testing.

However if your interface is developing into dozens of method you may want to step back and look at dividing it into smaller units then aggregate them. Not necessarily based on receiving and presenting but more logical divisions of your presentation UI.

For example you could have a IPresentationUI with two variables one is an interface of IPresentationDisplay and the other of IPresentationControl. The only registration routine you have will accept a IPresentationUI object. The class implementing the Prensentation layer would be implementing three interfaces IPresentationUI, IPresentationControl, and IPresentationDisplay.

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