# UML Generalization and Specialization

**In short:** Generalization links a specific class to a more general one. The specific class inherits the general class's characteristics and can add its own. Every instance of the specific class is also an instance of the general class.

## Explanation

Generalization is a relationship between a general class (the superclass) and a more specific class (the subclass). Specialization is the same relationship seen from the other direction: you start from the general class and add more specific ones. See UML Class Diagram for the diagram type.

**Notation.** A hollow triangular arrowhead marks the relationship. It points toward the more general class.

**Inheritance.** A specialized class inherits the characteristics of its general class. It may also add characteristics of its own.

**Abstract classes.** An abstract class defines common characteristics but has no direct instances of its own.

**Substitutability.** Every instance of a subclass is also an instance of its superclass. This underlies substitutability. The Liskov formulation says: if S is a subtype of T, objects of type T in a program may be replaced with objects of type S without altering desirable program properties.

**Generalization sets.** A set groups the specializations of one general class. Two properties describe a set:
- *Complete*: the set covers all permitted specializations. The UML 2.5 notation says "complete" and the metamodel says "covering". The maintainers kept both as synonyms.
- *Disjoint*: one instance can belong to only one specialization in the set.

**Where it appears.** One source states that generalization can be shown only on class diagrams and use case diagrams.

## Example

A shop models a general class "Payment". Two specific classes, "CardPayment" and "BankTransfer", each point to it with a hollow triangle. Both inherit what all payments share, such as an amount. Each adds its own details. "Payment" is abstract, so the shop never creates a plain payment. A card payment can be used wherever a payment is expected. If the set holds only these two classes and no payment is both, it is complete and disjoint.

## Trade-offs

Inheritance is an intimate relationship, and it has dangers. Superclass behavior can easily be broken, and changes to the superclass affect every subclass. Keep hierarchies shallow and use them only where substitution truly holds.

Two specific payment classes generalize to one abstract Payment class.

```plantuml
@startuml
abstract class Payment {
  amount
}
class CardPayment {
  cardNumber
}
class BankTransfer {
  iban
}
Payment <|-- CardPayment
Payment <|-- BankTransfer
@enduml
```

## Checks

- Generalization arrows use a hollow triangle and point to the more general class.
- Every subclass can stand in for its superclass, because each of its instances is also an instance of the superclass.
- Abstract classes are used only for shared characteristics and have no direct instances.
- Generalization sets state whether they are complete and whether they are disjoint.

## Related

- [UML Class Diagram](https://arc.fuet.ch/concepts/modeling-uml/class-diagram.md)
- [UML Class Diagram Relationship](https://arc.fuet.ch/concepts/modeling-uml/class-diagram-relationships.md)
- [UML Association](https://arc.fuet.ch/concepts/modeling-uml/association.md)
- [Aggregation vs. Composition](https://arc.fuet.ch/concepts/modeling-uml/composition-versus-aggregation.md)
- [Use Case Diagram](https://arc.fuet.ch/concepts/modeling-uml/use-case-diagram.md)
- [Common Class Diagram Modeling Mistakes](https://arc.fuet.ch/concepts/modeling-uml/common-class-diagram-modeling-mistakes.md)
- [UML Interface](https://arc.fuet.ch/concepts/modeling-uml/uml-interface.md)
- [Open-Closed Principle](https://arc.fuet.ch/concepts/principles/open-closed-principle.md)

## Sources

- [Understanding UML Generalization and Specialization | The Requirements Engineer](https://the-requirements-engineer.com/modeling/uml-generalization-and-specialization/) — the-requirements-engineer.com, accessed 2026-11-09
- [Class diagram - Wikipedia](https://en.wikipedia.org/wiki/Class_diagram) — en.wikipedia.org, accessed 2026-11-09
- [Liskov substitution principle - Wikipedia](https://en.wikipedia.org/wiki/Liskov_substitution_principle) — en.wikipedia.org, accessed 2026-11-09
- [Unified Modeling Language 2.5 (UML) FTF — Open Issues - OMG Issue Tracker](https://issues.omg.org/issues/UML25-339) — issues.omg.org, accessed 2026-11-09
- [Open Inheritance](https://martinfowler.com/bliki/OpenInheritance.html) — martinfowler.com, accessed 2026-11-09
