• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Factory Methods

 
vishal sodani
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please explain the concept of factory methods!!
 
Rahul Mahindrakar
Ranch Hand
Posts: 1869
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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.

------------------

Mahindrakar
IBM Application Server Forum Moderator
SCJP2
 
Eddy Chang
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 http://www.javaworld.com/javaworld/javaqa/2001-05/02-qa-0511-factory_p.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic