previous | start | next

Design: Class Relationships - class members

In addition, relationships between the set of classes should be made clear in the design phase. That is, some classes may need to use some of the other classes.

One class can use another class in several different ways:

In these examples the relationship is that one class uses another class by having a member of that class type.

This is called the has-a relation ship. One class has a member whose type is another class.

A PointSet has Points. The PointSet class will have a member (an array) to hold a collections of Points.

A Book has Chapters and an Index. A Book class might similarly, have a member that is an array of Chapter elements and another member of type Index.

The term aggregation is also used. For example, the class Book aggregates or has members of type Preface, Chapter, Appendix, and Index.



previous | start | next