MVC和命令模式 [英] MVC and command pattern

查看:75
本文介绍了MVC和命令模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好,这有点愚蠢.我正在尝试把头放在 MVC和命令模式.这些问题主要涉及到哪里 地点代码.

Ok, this is kinda dumb. I'm trying to wrap my head around the use of the MVC and Command Patterns. The questions basically concern where to place code.

在MVC模式中,命令在哪里实例化? 它们是由Controller创建的,还是完全包含在模型中,或者都不包含在模型中.

In the MVC pattern, where are the Commands instantiated? Are they created by the Controller, or are they contained fully in the Model or neither.

顺便说一句,如果不需要撤消/重做,应该使用Command模式吗?

BTW, Should one be using the Command pattern if there is no need of undo/redo.

致谢

推荐答案

尽管基于应用程序的需求/复杂性有很多变体,但是您通常会发现它们是在Controller中实现的.这是关于在MVC体系结构中使用命令模式的很棒的文章.我不确定您要构建哪种类型的应用程序,但是这里有更多资源显示了在不同应用程序堆栈上的实现.

While there are many variations based on the needs/complexity of an application, you typically find them implemented in the Controller. Here is a great article on using the Command pattern in an MVC architecture. I'm not sure what type of application you are building, but here are a few more resources that show implementations on different application stacks.

http://java.sun.com /blueprints/guidelines/designing_enterprise_applications_2e/web-tier/web-tier5.html

http://msdn.microsoft.com/en-us/library /ff647590.aspx

http://www.phpwact.org/pattern/model_view_controller

这篇关于MVC和命令模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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