设计模式和MVC框架 [英] Design Pattern and MVC Framework

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

问题描述

大家好,

我正在研究设计模式和MVC模型.我试图创建一个演示项目,但遇到了麻烦.我想同时实现MVC模型和工厂模式.

我只想从数据库中查询数据,但是我不确定要在哪里在Model或CONTROLLER上实现Factory.

伙计们,请告诉我我应该在哪里建厂以及为什么要建厂.

谢谢
NM

Hello everyone,

I was going through the design pattern and the MVC model. I tried to create a demo project but got stuck. I want to implement both MVC Model and Factory pattern.

I just want to query data from database but I am not sure where to implement the Factory as on MODEL or on CONTROLLER.

Guys please tell where should I implement the factory and why.

Thanks
NM

推荐答案

我同意前面的陈述,但有一点点提法,您应该真正想到要在何处实例化对象.如果您从视图中做到这一点,我会感到非常奇怪.当需要通过视图显示模型时,让控制器与工厂联系.
I agree with the previous statement with one small adition, you should really think where you''d like to instantiate the objects. I would find it really strange if you''d do that from the view. Let the controller talk to the factory when the model needs to be shown by the view.


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

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