使用C ++的MVC方法 [英] MVC approach with C++
问题描述
现在可以将MCV应用于C ++应用程序吗?插件管理器/插件去哪里甚至可以在模型或控制器?
谢谢!
编辑:
我的意思是C ++与GUI工具包,如QT / Wxwidgets / GTK +
还请帮助我如何在C ++中实现。我已经学会了如何在PHP中执行,但是你知道这两种语言有所不同!
EDIT2
http://forums.wxwidgets.org /viewtopic.php?f=1&t=30983
你实际上是在C ++中实现的。
-
。调用SomethingView类来使这一点清晰
-
使您的域对象不知道任何可视化或用户交互。您不需要将它们称为模型,但您可以
-
创建一组负责运行控制器角色的类:以某种方式依赖关系查看和可能的依赖注入模型类。示例: CppInject 。在任何情况下,控制器类都可以了解模型和视图类,所以重要的部分是:视图和模型对象之间的所有耦合都与控制器隔离。
-
此外,这意味着所有命令式编程也应该局限于控制器类:视图和模型应该是声明式的。这意味着,他们应该提供与其角色相关的服务,但避免与其他对象的直接互动作为副作用
-
它是不是真的,您需要通过事件风格的系统实现控制器和其他组件之间的通信,尽管这样的系统绝对有帮助,但肯定不需要。
-
惊喜!以上适用于任何语言或框架,除了当然语言,某种程度上已经强制MVC从头开始,即:ruby on rails
I have been learning PHP MVC pattern and it is pretty cool. have almost finished app and I can see how mess you can make a code without good design. Now can MCV be applied to C++ apps? Where does Plugin manager/Plugins go if that is even possible?In model or controller? Thanks!
EDIT:
I mean C++ with GUI toolkit like QT/Wxwidgets/GTK+ Also Please help me on how to implement in C++. I have learned how to do it in PHP but as you know the two languages are somehow different!
EDIT2
http://forums.wxwidgets.org/viewtopic.php?f=1&t=30983
how do you actually implement it in C++
make classes in charge of rendering know nothing about application details. Call them SomethingView classes to make this point clear
make your domain objects not know anything about visualization or user interaction. You don't need to call them Model, but you could
create a set of classes in charge of running the role of Controllers: wire somehow dependencies to view and model classes via dependency injection if possible. example: CppInject. In any case, controller classes can know both about model and view classes, so the important part is this: all the coupling between view and model objects is isolated to the controllers.
Also, this implies, that all imperative-style programming should be confined to the controller classes as well: view and model should be declarative-style. That means, they should offer services related to its role, but avoid direct interaction with other objects as side-effects
It is not true you need to implement communication between controllers and the other components with event-style system, although such system is definitely helpful, but certainly not required
surprise! the above applies to any language or framework, except of course languages that somehow already force MVC down your throat from the start, i.e: ruby on rails
这篇关于使用C ++的MVC方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!