With the help of object-oriented designers, inheritance is used to define relationships, such as the derived class is a kind of the base class.
A car is a kind o/7vehicle. An engineer is a kind of employee, which is a kind of'person. This relationship is called the ISA relationship.
Inheritance is not appropriate for relationships where one class has an instance of another. For example, an employee has a date of birth and a department has a manager. This relationship is called the HAS A relationship. The HAS A relationship is appropriate when the embedded object is singular and belongs to the class that embeds it. An employee's date of birth belongs to that employee. Even when another employee has the same birth-day, each one has a private copy of the data element.
No comments:
Post a Comment