Click here to Skip to main content
15,562,561 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
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
Posted
Comments
Legor 6-Sep-11 6:56am    
I think it depends what you want to create with your factory. In a MVC application imo its usually used to configure your application with different GUI styles. But I dont really see how a factory fits in either of the MVC layers. It's more like a separate concept for the creation of objects. This doesn't mean a factory can't be usefull in a MVC application but i would keep it separated from the other components.

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900