26.2. Generalization

The concepts CashPayment, CreditPayment, and CheckPayment are all very similar. In this situation, it is possible (and useful[1]) to organize them (as in Figure 26.1) into a generalization-specialization class hierarchy (or simply class hierarchy) in which the superclass Payment represents a more general concept, and the subclasses more specialized ones.

[1] Later in the chapter, we will investigate reasons to define class hierarchies.

Figure 26.1. Generalization-specialization hierarchy.

Note that the discussion of classes in this chapter refers to conceptual classes, not software classes.

Generalization is the activity of ...

Get Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and the Unified Process, Second 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.