liveBook · Manning

Class hierarchy

As explained in Data-Oriented Programming: Reduce software complexity

A class hierarchy is an arrangement of classes connected by inheritance relationships.

A class hierarchy arranges classes through inheritance, placing shared behavior in a base class and specialized behavior in derived classes. In a library system, Librarian and Member inherit login ability from User. section 1.2.4

When a tiny feature is not tiny

Theo is asked to add VIP members who can add book items independently. He separates the requirement into two facts: VIP members are members, and VIP members need a capability currently implemented in Librarian::addBookItem. Because that code is locked into a class method, the change may require a new VIPMember class and further hierarchy design rather than simple reuse. section 1.2.4

Figure 1.15 The part of the class diagram that deals with members and librarians

Inspect the member-and-librarian class diagram to see how User supplies shared login behavior. section 1.2.4

Figure 1.16 A class diagram for a system with VIP members

Compare the expanded diagram showing how VIP members alter the original design. section 1.2.4

How Data-Oriented Programming: Reduce software complexity covers it

How deep it goes
Explains inheritance and requirement-driven hierarchy changes, stopping short of implementation details beyond class methods.
Examples
Uses User, Member, Librarian, VIPMember, login behavior, and adding book items as concrete examples.
What you can do after
Evaluate why adding a capability to a class hierarchy can require structural changes instead of straightforward code reuse.
How it connects
Connects inheritance, base classes, derived classes, class diagrams, methods, and code reuse.

Also explained in

Compare how 4 books explain class hierarchy →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data-Oriented Programming: Reduce software complexity. The section links point to the parts of the book it draws on.