Class diagrams: abstract vs concrete classes
简介 / Introduction
An abstract class cannot be instantiated directly — it defines a skeleton of attributes and methods that its subclasses must implement. A concrete class inherits from the abstract class and provides full implementations. This article shows how to model this pattern in both PlantUML and Mermaid.
PlantUML 版
1 | abstract class Animal { |
The abstract keyword declares the abstract class, and {abstract} marks abstract methods. extends denotes inheritance.
Mermaid 版
1 | classDiagram |
Mermaid uses the <<abstract>> stereotype label to mark abstract classes, and <|-- for generalization (inheritance).
对比 / Side-by-side
| Feature | PlantUML | Mermaid |
|---|---|---|
| Abstract class declaration | abstract class Name |
class Name { <<abstract>> } |
| Abstract method | {abstract} +method() |
+method() void (no body) |
| Inheritance | A extends B |
`A < |
| Visibility | + public, # protected |
+ public, # protected |
小结 / Wrap-up
PlantUML’s abstract keyword makes abstract class syntax more compact, while Mermaid requires an explicit <<abstract>> label. Both clearly express the core OOP concept: an abstract class defines a contract, and concrete classes provide the implementation.
- Title: Class diagrams: abstract vs concrete classes
- Author: puml.online
- Created at : 2026-10-16 09:00:00
- Updated at : 2026-10-19 01:07:19
- Link: https://puml.online/blog/class-diagram-abstract-concrete-en/
- License: This work is licensed under CC BY-NC-SA 4.0.