Class diagrams: abstract vs concrete classes

Class diagrams: abstract vs concrete classes

puml.online

简介 / 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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
abstract class Animal {
{abstract} +makeSound(): void
+eat(): void
}

class Dog extends Animal {
+makeSound(): void
}

class Cat extends Animal {
+makeSound(): void
}

Animal <|-- Dog
Animal <|-- Cat

The abstract keyword declares the abstract class, and {abstract} marks abstract methods. extends denotes inheritance.

Mermaid 版

1
2
3
4
5
6
7
8
9
10
11
12
13
14
classDiagram
class Animal {
&lt;&lt;abstract&gt;&gt;
+makeSound() void
+eat() void
}
class Dog {
+makeSound() void
}
class Cat {
+makeSound() void
}
Animal <|-- Dog : extends
Animal <|-- Cat : extends

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.
On this page
Class diagrams: abstract vs concrete classes