aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Problem with the problem Creational Pattern solves 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 "Problem with the problem Creational Pattern solves" Watch "Problem with the problem Creational Pattern solves" New topic
Author

Problem with the problem Creational Pattern solves

Tulsi Rai
Ranch Hand

Joined: Jun 26, 2002
Posts: 55
Hi All,
Every creational pattern states that
Sometimes, an Application (or framework) at runtime, cannot anticipate the class of object that it must create. The Application (or framework) may know that it has to instantiate classes, but it may only know about abstract classes (or interfaces), which it cannot instantiate. Thus the Application class may only know when it has to instantiate a new Object of a class, not what kind of subclass to create.


I am having problem particularly with the statement "....can not anticipate the class of object that it must create, may only know when it has to instantiate a new object of a class ,not what kind of subclass to create...."

why can't we anticipate the class of object that's going to be created? could you please give me some real world example in easy-to-undestand way?
thanks.
[ August 18, 2004: Message edited by: t ray ]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
I think this description is a little bit, well, besides the point.

The point, to me, is that the patterns decouple the when from the what. That is you can have one part of the application decide what classes to instanciate (by creating the appropriate factory or something) and another part of the application decide when to instanciate them.

Does that help?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Tulsi Rai
Ranch Hand

Joined: Jun 26, 2002
Posts: 55
thanks Ilja, i am still trying hard to make it sense to me.hopefully i will get it over.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I'm just this minute working on a factory that gets a map of keys and classnames from configuration. When somebody asks for a handler for some input object the factory looks up a classname with a key from the input and creates a new handler. This lets us add new handlers without recompiling the object that's using them. Good clean fun.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with the problem Creational Pattern solves