Home All Groups Group Topic Archive Search About
Author
13 Jul 2006 2:36 PM
dan
Hi,

In my application I have used the Factory Design method to model a portion
of my business layer.  Each object I create using the factory method share
the same actions (subs/function) which I use an interface to interact with
and it works great.  However, I have run into a problem because each object
might share the same actions however the attributes (properites) are
different (hidden) and I need acess to them. At the time of the design these
properties were going to remain hidden but now with a change in business
logic I need access to them.  Without completely breaking my design is there
a solution out there to apply?

Thanks

Author
13 Jul 2006 3:15 PM
Ignacio Machin ( .NET/ C# MVP )
Hi,

"dan" <d**@e.com> wrote in message
news:eZv2QmopGHA.4196@TK2MSFTNGP04.phx.gbl...
> Hi,
>
> In my application I have used the Factory Design method to model a portion
> of my business layer.  Each object I create using the factory method share
> the same actions (subs/function) which I use an interface to interact with
> and it works great.  However, I have run into a problem because each
> object
> might share the same actions however the attributes (properites) are
> different (hidden)

private you mean?

> and I need acess to them. At the time of the design these
> properties were going to remain hidden but now with a change in business
> logic I need access to them.  Without completely breaking my design is
> there
> a solution out there to apply?


The idea of having a common interface is that you can treat any instance in
the same way, no matter what type that instance is.
What you want will break the above. You will NEED TO KNOW the exact type of
the instance created in order to access its particular properties.


Are you sure this is the only way to go?

At the very last resort you could a lookup method:

public object GetPropertyValue( string propertyname)
{
             switch propertyname
    {
         case "prop1" return 1;
         case "prop2" return  "whatever";
    }
}

--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Are all your drivers up to date? click for free checkup

Author
13 Jul 2006 3:23 PM
dan
Thanks for the post.  I do need to get some properties from each object and
these properties are not common between the objects.  Do you have any other
ideas?

Thanks

Show quoteHide quote
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:OG8Xk8opGHA.4760@TK2MSFTNGP05.phx.gbl...
> Hi,
>
> "dan" <d**@e.com> wrote in message
> news:eZv2QmopGHA.4196@TK2MSFTNGP04.phx.gbl...
>> Hi,
>>
>> In my application I have used the Factory Design method to model a
>> portion
>> of my business layer.  Each object I create using the factory method
>> share
>> the same actions (subs/function) which I use an interface to interact
>> with
>> and it works great.  However, I have run into a problem because each
>> object
>> might share the same actions however the attributes (properites) are
>> different (hidden)
>
> private you mean?
>
>> and I need acess to them. At the time of the design these
>> properties were going to remain hidden but now with a change in business
>> logic I need access to them.  Without completely breaking my design is
>> there
>> a solution out there to apply?
>
>
> The idea of having a common interface is that you can treat any instance
> in the same way, no matter what type that instance is.
> What you want will break the above. You will NEED TO KNOW the exact type
> of the instance created in order to access its particular properties.
>
>
> Are you sure this is the only way to go?
>
> At the very last resort you could a lookup method:
>
> public object GetPropertyValue( string propertyname)
> {
>             switch propertyname
>    {
>         case "prop1" return 1;
>         case "prop2" return  "whatever";
>    }
> }
>
> --
> --
> Ignacio Machin,
> ignacio.machin AT dot.state.fl.us
> Florida Department Of Transportation
>
Author
13 Jul 2006 3:36 PM
Demetri
I don't know how much time you have or how much re-factoring you are willing
to do but the MVP (Model View Presenter) pattern might be a good solution for
you. Basically the idea is the UI and Presentation are separate logical
layers. I'm not sure if it will fit what you need but decide for yourself.

For details check out the article in the latest MSDN mag.

http://msdn.microsoft.com/msdnmag/issues/06/08/DesignPatterns/default.aspx

--
-Demetri


Show quoteHide quote
"dan" wrote:

> Thanks for the post.  I do need to get some properties from each object and
> these properties are not common between the objects.  Do you have any other
> ideas?
>
> Thanks
>
> "Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
> in message news:OG8Xk8opGHA.4760@TK2MSFTNGP05.phx.gbl...
> > Hi,
> >
> > "dan" <d**@e.com> wrote in message
> > news:eZv2QmopGHA.4196@TK2MSFTNGP04.phx.gbl...
> >> Hi,
> >>
> >> In my application I have used the Factory Design method to model a
> >> portion
> >> of my business layer.  Each object I create using the factory method
> >> share
> >> the same actions (subs/function) which I use an interface to interact
> >> with
> >> and it works great.  However, I have run into a problem because each
> >> object
> >> might share the same actions however the attributes (properites) are
> >> different (hidden)
> >
> > private you mean?
> >
> >> and I need acess to them. At the time of the design these
> >> properties were going to remain hidden but now with a change in business
> >> logic I need access to them.  Without completely breaking my design is
> >> there
> >> a solution out there to apply?
> >
> >
> > The idea of having a common interface is that you can treat any instance
> > in the same way, no matter what type that instance is.
> > What you want will break the above. You will NEED TO KNOW the exact type
> > of the instance created in order to access its particular properties.
> >
> >
> > Are you sure this is the only way to go?
> >
> > At the very last resort you could a lookup method:
> >
> > public object GetPropertyValue( string propertyname)
> > {
> >             switch propertyname
> >    {
> >         case "prop1" return 1;
> >         case "prop2" return  "whatever";
> >    }
> > }
> >
> > --
> > --
> > Ignacio Machin,
> > ignacio.machin AT dot.state.fl.us
> > Florida Department Of Transportation
> >
>
>
>

Bookmark and Share