File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes OO, Patterns, UML and Refactoring and the fly likes Factory Methods Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Reply locked New topic
Author

Factory Methods

santhoshK babu
Greenhorn

Joined: Jul 25, 2006
Posts: 22
Can Any one Explain me the question below..

Thanks in Advance

What is factory methods? When it is appropriate to use?

Why should we go for factory method?
hemadri raju
Greenhorn

Joined: Mar 28, 2006
Posts: 15
whenever we want to have some control over the number of objects to be created for a class.

in such cases we create a private constructor, and static method in that class. and we call the private constructor from that static method. we can have count of objects created for that class using a static variable.
sentil kumar
Ranch Hand

Joined: Oct 23, 2006
Posts: 74
Pattern p = Patten.compile("\\d");
Pattern p = Patten.compile("[a-s]");
here the patten object is created by the Pattern class, based on the given input..

this is example for factory pattern
Carlos G�mez
Ranch Hand

Joined: Sep 06, 2006
Posts: 56
also:

DateFormat.getDateInstance()
NumberFormat.getInstance()
NumberFormat.getCurrencyInstance()
NumberFormat.getPercentInstance()
Calendar.getInstance()

SCJP 1.4
SCJP 5.0
Vaibhav Chauhan
Ranch Hand

Joined: Aug 16, 2006
Posts: 115
do we use these factory methods only when we want to limit the maximum no of objects that can be created or is there any other use of these methods as well ??
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18670
OK, I guess people really really want to discuss this here for some unknown reason. Whatever. Enjoy...


"I'm not back." - Bill Harding, Twister
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Factory Methods
 
Similar Threads
factory methods???????
Factory Class??
Factory class
Factory Methods
factory methods