my dog learned polymorphism*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Connection Factory MVC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Connection Factory MVC" Watch "Connection Factory MVC" New topic
Author

Connection Factory MVC

Breno Ribeiro
Greenhorn

Joined: Jan 27, 2012
Posts: 15
Hi,
I wanna know, according to the MVC, where should I put my Connection Factory class?
controller package? util package? connection package? dao package?
Praveen Kumar M K
Ranch Hand

Joined: Jul 03, 2011
Posts: 256
Breno,

In my opinion, MVC and Factory classes are 2 different paradigms and I necessarily dont see a connection from which one can generalize something.

MVC stands for Model(DAO and Data layer), View(JSP, HTML, Presentation layer) and Controller(The layer that connects View and Model). Its a classic design technique to build an application. It separates areas of concern, i.e., you have 3 separate layers, and it promotes loose-coupling, extensibility and re-usability. What that means is, is that you can work on any layer without affecting the other layers.

A Factory is a design pattern where in you delegate the creation of objects to a factory class. So in case I need to create an object, I can place a request to the factory and its the factory which will perform some logic and give me the created instance. This gives more of an authority to the factory and gets rid of spurious creation of objects.

So, you can use the factory class across any of the layers. If you wanted a factory for the DAO classes, you can use the DAOFactory class. If you want it at the controller level you can create a ControllerFactory and so on.

The way that I follow is to have a factory package and put all my factory classes into that package.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connection Factory MVC