I am designing a solution in Java, and I have to create n objects, based on property values. I am using factory design pattern.
Using the classic example of shape and shape types
String myShapes="circle,square,circle,rectangle" // This is from a property file
for ( shapeType : myShapes.split("," ) {
ShapeFactory shapeFactory = new ShapeFactory();
Shape shape1 = shapeFactory.getShape(shapeType );
shape1.doSomething();
}
Can someone tell me whether the following is right approach in creating the objects? I don't know how many objects I will have to create during compile time.
Aucun commentaire:
Enregistrer un commentaire