The Artima Developer Community
Sponsored Link

Legacy Design Forum
Canonical Object Idiom

Advertisement

Advertisement

This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Creation of objects from an inheritance hierarchy

Posted by Kumar on January 08, 2001 at 11:17 PM

Hello,
I am not sure if this is the right forum to address this.

I have designed a class hierarchy which was pretty straight-forward for my application.
For eg, there's a base(abstract) class A. Class B and Class C are currently derived from A. One of the major objectives of this inheritance hierarchy is to plug in new classes for new requirements, for eg, Class D can be plugged in to be derived from Class A for additional requirements.
This fits well into my plan until now!
Objects of class B and C are currently instantiated based on a data format. If the data format starts with a specific pattern, B is created, and there's a specific pattern for C as well.
I have currently hard-coded it.
if (pattern="abx", new B());
else if (pattern = "xyc" new C());
Obviously, if I have a new class D, the plug-in is not seamless, as I still have to write code to create an object D.
Is there a simple design pattern (for a relatively new OO team) to solve this problem.
Thanks
Kumar



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us