Re: Dynamic inheritance

From: James Harris (no.email.please)
Date: 12/15/04


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


Relevant Pages

  • Re: The Philosophy of Programming?
    ... less trivial to ensure that the string length has not been altered. ... > lowers psychological complexity for most intelligent readers. ... For most intelligent programmers, the laziness principal applies. ...
    (comp.programming)
  • Re: A C++ Whishlist
    ... > people from inclusion in a standard. ... > creating their own string class. ... >>don't want an ever increasing size of exception specification on each ...
    (comp.lang.cpp)
  • Re: Hash functions (was: Maximum String size in Java?)
    ... snip ... ... Inserted with sx31hsh and ssfh_ph in 0.385 secs ... your string library has problems with them speaks for itself. ... published your SFH code with the shifted and undersized ints. ...
    (comp.programming)
  • Re: Zero terminated strings
    ... including when you do things like string concatenation etc ... Simple "tricks" are all you need to implement a decent link level ... <snip basic link layer protocol> ...
    (comp.lang.c)
  • Performance with reading large numbers of files...
    ... I have a small test application that recurses a directory and adds all the file names to a string collection. ... RecurseDirs, sDiskFiles); ... private static void RecurseDirs ...
    (microsoft.public.dotnet.framework.performance)