• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with the problem Creational Pattern solves

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Tulsi Rai
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Ilja, i am still trying hard to make it sense to me.hopefully i will get it over.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic