Factory pattern and building object
- From: opamail1-googlenews@xxxxxxxxx
- Date: 26 Sep 2005 13:46:10 -0700
I am creating a FlowChart type GUI application which has several
diagram items. I have a DiagramItemFactory which creates concrete
diagram item objects. I call this factory to create diagram items at
runtime via drag and drop, insert or other. Then I serialize my diagram
to an XML file. Everything is ok so far.
Sample C# code:
public class DiagramItemFactory
{
public DiagramItem CreateItem(DiagramItemType itemType)
{
DiagramItem diagramItem = null;
switch (itemType)
{
case DiagramItemType.Square:
Square square = new Square(); // square class
diagramItem = square;
break;
case DiagramItemType.Circle:
Circle cirlce = new Circle(); // circle class
diagramItem = square;
break;
}
return diagramItem;
}
}
My problem is when I open the file a go through the diagram items
defined in the file, I want to the DiagramItemFactory again to create
the diagram items for the diagram, but the problem is that
the factory only creates the default diagram items and the file
also contains size, color, coordinate and other properties.
Is there another pattern I should be using for opening up the file
and rendering the flow chart diagram?
Thank You,
Opa
.
- Follow-Ups:
- Re: Factory pattern and building object
- From: Nick Malik [Microsoft]
- Re: Factory pattern and building object
- From: Abhijat Vatsyayan
- Re: Factory pattern and building object
- From: iamfractal
- Re: Factory pattern and building object
- From: femto
- Re: Factory pattern and building object
- Prev by Date: Re: A question about Tony Johansson and a paper
- Next by Date: Re: Why encapsulate state pattern......
- Previous by thread: Re: How to create an ERD with Rational Rose?
- Next by thread: Re: Factory pattern and building object
- Index(es):