in reply to Re: •Re: inheritance and object creation
in thread inheritance and object creation
something else to keep in mind, is the distinction between "IS-A" and "is-instance-of"
When designing a class hierarchy, the concepts of IS-A and HAS-A get thrown arround alot, but you have to always keep in mind that you are talking about "classes of things" -- not hte things themselves.
All i know about your data and your application is what you've posted in this thread, so maybe there's more going on then i understand, but it seems to me that "AcmeLtd" is an instance-of "Company", and "AcmeLtd IT" is an instance-of "Company::Division". Unless of course, you have some reason to instantiate many different instances of AcmeLtd ?
The nature of your data confuses me, so instead let's Imaging you are dealing with Animals. you've got the class "Animal" and hte subclasses Dog and Cat (a Dog IS-A Animal). now based on the nature of your data, do you want lots of instances of "Dog" representig a breed as an attribute, or do you want a seperate subclass for each breed, with each instance representing a physical dog with a name?
This...
...verses, this...# Dog ISA Animal my $german_sheperd = new Dog(BIG, FURRY); my $collie = new Dog(MEDIUM, SHORT_HAIRED); my $poodle = new Dog(SMALL, GOOFY);
# Dog ISA Animal # Dog::Poodle ISA Dog # Dog::Collie ISA Dog my $fluffy = new Dog::Poodle('fluffy'); my $spot = new Dog::Poodle('spot'); my $fido = new Dog::Collie('fido'); my $stray = new Dog();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: •Re: inheritance and object creation
by knew (Monk) on Feb 24, 2004 at 00:29 UTC |