12.3 First Design

When designing a project like our graphics module, it is a good idea to begin by making a list of the kinds of objects involved and the relationships among those objects. As we make the list of objects, we will try to identify two important kinds of relationships among the objects: IS-A and HAS-A.

The IS-A relationship describes two objects, one of which is a more specific instance of the other. For example, a square is a more specific instance of a rectangle, and a circle is a more specific instance of an ellipse. As we identify these IS-A relationships, we also look for functionality that each of the instances has in common. Classes with IS-A relationships are ideal for a design using inheritance.

A HAS-A relationship describes ...

Get Python Programming in Context, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.