Re: Dynamic inheritance
From: James Harris (no.email.please)
Date: 12/15/04
- Next message: Laurent Bossavit: "Re: Accesing the private members between the instance of same class"
- Previous message: Rizwan: "How to get UML from database?"
- In reply to: H. S. Lahman: "Re: Dynamic inheritance"
- Next in thread: Robert C. Martin: "Re: Dynamic inheritance"
- Reply: Robert C. Martin: "Re: Dynamic inheritance"
- Reply: H. S. Lahman: "Re: Dynamic inheritance"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 15 Dec 2004 21:28:31 -0000
"H. S. Lahman" <h.lahman@verizon.net> wrote in message
news:Xy0sd.8$cJ4.5@trndny05...
> Responding to Harris...
<snip>
> Something is wrong with this picture. How could the object that creates
> the device instance not know what sort of device to create?
It has to query the device itself to find out what type it is. See the
example below.
<snip>
> Dealing with instantiation in a dynamic context is what the GoF
> construction patterns do. For example, in the Abstract Factory pattern
> the context determines how to instantitate the relationship between
> [Client] and [AbstractFactory] to access the correct [AbstractFactory]
> subclass. Once that relationship is instantiated the Client just invokes
> the generic method at the superclass level and the right product
> instance(s) pops out.
I was thinking of (pseudocode)
loop (from n=0) {
read device_address (break if EOF)
Device[n++] = create/new objClass (device_address)
}
where the objClass constructor would interrogate the device at the address
given and return an instance of the correct type. All instance types would
support certain methods - e.g. GetName - but get the info from the device
in a different way. e.g devicetypeA may require a menu string 4,6 to get
the name but a devicetypeB may require a menu string 4,7 to be passed to
the node. I wanted to wrap the menu string in a GetName method but have the
implementation of that method to be appropriate for the node type.
Sorry, I didn't follow what you meant by GoF.
> BTW, you use the term 'instate' several times. I assumed that you meant
> 'instantiate', but I am beginning ot suspect you meant something else.
I guess I meant, "instatiate."!
-- Cheers, James
- Next message: Laurent Bossavit: "Re: Accesing the private members between the instance of same class"
- Previous message: Rizwan: "How to get UML from database?"
- In reply to: H. S. Lahman: "Re: Dynamic inheritance"
- Next in thread: Robert C. Martin: "Re: Dynamic inheritance"
- Reply: Robert C. Martin: "Re: Dynamic inheritance"
- Reply: H. S. Lahman: "Re: Dynamic inheritance"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|