Re: Factory pattern and building object
- From: "Nick Malik [Microsoft]" <nickmalik@xxxxxxxxxxxxxxxxxx>
- Date: Fri, 30 Sep 2005 08:41:38 -0700
> is it ok for me to change the contructs of pattern tailored to my
> needs, or is doing so
> going to cause unforseable problems later on in my design? I can give
> a more concrete
> example if needed.
Of course, it is OK. However, you need to make sure that you are still
sticking to the principles.
I'm perplexed about why the deserialization process loses the identity of
the concrete object. It shouldn't. If you serialize concrete object A,
then when you deserialize, you should get A, not the identity of the base
class. Note that the builder is a creational pattern. It is fine for it to
be bound to the concrete types. The point of the builder is to seperate
creation from use, even when creation is an involved process. Therefore,
the factory object that you use to create the object is not the same as the
builder object used to deserialize.
Does that help?
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
<opamail1-googlenews@xxxxxxxxx> wrote in message
news:1127922900.972988.320060@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> Thanks for the replies.
> I'm using my own serialization, but serialization is off topic.
> My issue is building the diagram from a file containing diagram items
> and their properties (color, size, location, etc...). I've since
> implemented
> a builder pattern, but looking at the constructs of this pattern, there
> no
> consideration for passing in arguments. The constructs of the builder
> pattern show
> a Construct method in the Director class, but with no arguments.
> Generally speaking
> is it ok for me to change the contructs of pattern tailored to my
> needs, or is doing so
> going to cause unforseable problems later on in my design? I can give
> a more concrete
> example if needed.
>
>
>
>
> Nick Malik [Microsoft] wrote:
>> <opamail1-googlenews@xxxxxxxxx> wrote in message
>> news:1127767570.752816.225950@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>> >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.
>>
>> > 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.
>>
>> Hi Opa,
>>
>> If you are using the serialization capabilities of the framework, it will
>> serialize the concrete object and all public properties, not just the
>> generic object. How are you serializing your object? Also, your snippet
>> shows the factory but not the definition of the child objects. The
>> attributes that you use in the code of the objects will determine both
>> how
>> the objects will be serialized and how they will be deserialized.
>>
>> See:
>> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnexxml/html/xml01202003.asp
>>
>> Also, you will get much more specific help on your C# problems by posting
>> to
>> the microsoft.public.dotnet.languages.csharp newsgroup.
>>
>> --
>> --- Nick Malik [Microsoft]
>> MCSD, CFPS, Certified Scrummaster
>> http://blogs.msdn.com/nickmalik
>>
>> Disclaimer: Opinions expressed in this forum are my own, and not
>> representative of my employer.
>> I do not answer questions on behalf of my employer. I'm just a
>> programmer helping programmers.
>> --
>
.
- References:
- Factory pattern and building object
- From: opamail1-googlenews
- Re: Factory pattern and building object
- From: Nick Malik [Microsoft]
- Re: Factory pattern and building object
- From: opamail1-googlenews
- Factory pattern and building object
- Prev by Date: Re: why program to interface is better design?
- Next by Date: Re: Why encapsulate state pattern......
- Previous by thread: Re: Factory pattern and building object
- Next by thread: Breaking the Last Dependency in C++?
- Index(es):
Relevant Pages
|