On Sep 30, 2010, at 12:28, Remco Poelstra wrote:

> I've a class that represents a general piece of hardware. Subclasses of that 
> class represent more specific versions of that hardware. When I scan the 
> network for hardware, I first only know some basic properties of the hardware 
> and only after some more queries I'll know all details. I thought it would be 
> a good thing to instantiate from the base class when I detect the hardware 
> and then change the class to a more specific class as I find out more about 
> the hardware.
> But how do I change a class? I know about the ISA pointer, but changing it 
> doesn't allocate any additional variables.
> What would be a nice solution to this problem?

It's not at all obvious that having your class(es) "represent" your hardware is 
the right way to approach this.

What are you actually trying to achieve? If the various kinds of hardware are 
differentiated by their "properties", then a single class encapsulating the 
possible properties (including a specification of which properties are actually 
present for each device) may be all that you need.

You would only use a class hierarchy if the class has significant shared 
*behavior*, plus behavior that is specific to each device type. Note that I'm 
talking about class behavior, not device behavior. The device behavior isn't 
relevant to the class behavior, unless the class is a software simulation of 
the device.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to