Combining Proto and Parent Inheritance

Use Parent Inheritance for Inheriting Data

In general, you should reserve parent inheritance for inheriting shared data. It is unusual to use it to inherit behavior. Here is the rationale:

For example, the method might assign to self.slot, which creates a slot in the child. Or, the method might iterate over its children.

This means that in hierarchies (see FIGURE 4.8), when you need to call MethodA from inside MethodB, you should do so with this syntax:

:Parent():MethodA()
and not this syntax:

:MethodA()
The former sends a message to the parent object; the latter sends a message to the child object.

FIGURE 4.8 : A hierarchy of frames.


An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.

Last modified: 1 DEC 1996