September 23, 2023

Hierarchy and Inheritance


The class library is structured as a hierarchy. This is a tree-like structure with the Object class acting as its root. All other classes are derived, or subclassed, either directly or indirectly from Object. Alternatively, Object is the superclass, directly or indirectly, of all other classes in the Smalltalk system.

Object class has no attributes of any description, it is utterly abstract. Any subclasses of Object will implement more detail.

If we consider just one part of the LWs class hierachy:


A subclass inherits the protocol of its superclass. Consequently, Amphibian inherits the protocol of Object. Frog objects can understand all the messages in the protocol of Amphibian and Object, as well as those in the Frog protocol. HoverFrog objects can understand all the messages in the protocol of Frog, Amphibian and Object as well as the messages in the HoverFrog protocol, and so on.

What else is inherited? A subclass inherits the attributes of its superclass. HoverFrog objects are a kind of Frog object, but are more specialised. Like Frog objects they possess position and colour attributes although they have something extra, height.

You can download a Word file (38 kb) illustrating part of the LearningWorks Smalltalk hierarchy here.

Next page » Smalltalk Variables

Previous page « Class
































































Up to top of page