Quick Index
Overview


Components (ivars) are the primary way achieve code reuse.

These are used interchangeably:


Concepts


Here we show a Student object with four components (ivars).

The "has-a" relationship test is helpful to identify components:

  • Student has-a name
  • Student has-a major
  • Student has-a advisor
  • Student has-a list of courses

All of these "has-a" statements sound reasonable, so we would know we are on the right path using components (ivars).
Here we show a Car object with three components (ivars).
Here we show a Team object with two components (ivars).

Also see composition over inheritance....