answersLogoWhite

0

In database design, object-oriented programming, and knowledge representation, we often describe the relationship between two things as either "is-a" or "has-a" (but not both).

For example,

An avocado "is-a" fruit. (An avocado is a specific kind of fruit. A fruit is a generalization of things like an avocado. An avocado has all the things and characteristics that all fruit have -- an outer skin, an edible flesh, grows on plants, etc.)

An avocado "has-a" seed. (An avocado contains a seed. The seed is one of several parts of an avocado.)

(Many people find this "is-a" term more understandable than the terms "meronym" and "hyponym").

When writing computer programs, confusing these two kinds of relationships is a common source of bugs.

The "is-a" relationship is often represented in a program using "class inheritance", subclasses (and superclasses).

The "has-a" relationship is often represented in a program using a class variable.

The class variable is typically a basic type for exclusive things, such as "birthday".

The class variable is typically a reference to a class as a class variable for shared items, such as "mother".

User Avatar

Wiki User

13y ago

What else can I help you with?