|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Interface QuestionHi,
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 Hi,
"dan" <d**@e.com> wrote in message private you mean?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) > and I need acess to them. At the time of the design these The idea of having a common interface is that you can treat any instance in > 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 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 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 > 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 -- Show quoteHide quote-Demetri "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 > > > > >
Other interesting topics
Convert HTML to Image
Visual studio 2005 Stored Procedure with parameter How to convert a string to MemoryStream Julian dates question Parsing a complicated date time Can't inherit from System.Drawing.Image What wrong my Updating Northwind Syntax Win[C#] connect to Oracle server by using csharp WinForm Communications in .NET |
|||||||||||||||||||||||