Re: Object inheritance question...
Re: Object inheritance question...
- Subject: Re: Object inheritance question...
- From: Brennan <email@hidden>
- Date: Tue, 27 Sep 2005 15:25:53 +0200
On 26/9/05 at 17:01, Brendan Wilde <email@hidden> wrote:
> I have a basic understanding of objects but i am having problems with a
> concept can someone point
> me in the right direction, refer to below... I want to pick which
> object my new objects inherit from, at the moment i can only make
> objects inherit from a single parent, but need to have a variable
> amount of parents and then various children off each. For example 5
> "street" objects each with various "house" objects.
> So how do i make a "house" for my new street object that inherits all
> of streets variables and methods etc?
> An example would be great. Thanks Brendan...
Something may be wrong here conceptually.
Typically class B inherits class A's properties and methods because
objects of class B are intended to resemble objects of class A in some
way, and most usefully because there are classes C, D and E, which are
also supposed to descend from class A.
There is an important difference, often mentioned when describing OOP,
between an "is a" and a "has a" relationship.
A cat *is a* mammal, a dog *is a* mammal, so they both inherit milk glands
from the mammal class. (Mammal in turn descends from the Vertebrate class
etc.)
A street "has a" house, it does not make sense to 'go for a walk down the
house', so it's not conceptually right for the house class to inherit from
the street class. In this case we would say that the street *contains*
some houses. A house is an *element* of a street, not a special kind of
street.
House (like garage, shed and skyscraper) might more usefully descend from
the 'building' class.
We might also imagine a 'one way street' class, or a cul-de-sac (or
whatever that's called in US English) descending from the 'street' class.
The problem is that AppleScript uses the ambiguous word 'parent' for
inheritance, which is often (conceptually) used to denote 'container' as
well as 'ancestor'.
The choice of the word 'parent' was IMNSHO a mistake, because it confuses
even those who think they know what they are talking about.
So use the 'has a'/'is a' test if you are in doubt whether the 'parent'
should be an ancestor or a container.
Brennan
--
Brennan Young
"The devotee believes that Krishna appears when his name is called. The guru understands that Krishna appears in the spaces between the name calling."
-Swami Wassermann
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden