MVC是否定义一个控制器如何与另一个控制器进行通信? [英] Does MVC define how one controller should communicate with another?

查看:168
本文介绍了MVC是否定义一个控制器如何与另一个控制器进行通信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我指的是一般的MVC设计模式(定义见维基百科)。当进行GUI密集型应用程序时,我通常会有许多控制器,有时一个控制器可以将事件发送给另一个控制器。



MVC一般定义了控制器应该如何与控制器通信?控制器可以是层次结构中更高的控制器的模型吗?



示例
假设我有一个窗口(由控制器/模型/视图表示),该窗口有能力启动另一个子窗口。子窗口是模态的,并且将接受某些输入。输入将影响主窗口中的某些进程。

解决方案

否。你不能用MVC这样做。您要使用以下两种之一的某种分层模式:




I am referring to the general MVC design pattern (as defined in Wikipedia). When doing a GUI-intensive application, I would generally have many controllers, and sometimes a controller could send an event to another controller.

Does MVC in general defines how controller should communicate with controller? Could a controller be the model for a controller higher up in the hierarchy?

Example Suppose I have a window (which is represented by a controller/model/view), and that window is capable of launching another sub-window. The sub-window is modal, and will accept certain input. The input will affect certain processes in the main window.

解决方案

No. You can not do that with MVC. You want to use some kind of hierarchical pattern like one of the following two:

这篇关于MVC是否定义一个控制器如何与另一个控制器进行通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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