File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Factory Methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Factory Methods" Watch "Factory Methods" New topic

Factory Methods

vishal sodani
Ranch Hand

Joined: Aug 26, 2000
Posts: 127
Please explain the concept of factory methods!!
Rahul Mahindrakar
Ranch Hand

Joined: Jul 28, 2000
Posts: 1868
This is a Gamma Et all pattern defined in the Design patterns book. Lets say we have a method defined like this.

An Object invoking the getMan method does not know which particular instance is created and is returned a Man. When he invokes walk on the Man Object returned he is returned 5 if the instance created is Rahul or 10 if the instance created is Sham. The method getman(..)
is the Factory.


IBM Application Server Forum Moderator
Eddy Chang

Joined: Apr 05, 2001
Posts: 27
Here's an article at javaworld that explains factory methods that you might find helpful.
Factory methods:
How do you employ factory methods to your best advantage
I agree. Here's the link:
subject: Factory Methods
It's not a secret anymore!