Skip to main content

Class diagrams

Overview​

Class diagrams are essential tools in object-oriented modeling. They're used for both high-level design of an application's structure and detailed modeling that can be turned into code. You can also use class diagrams for data modeling. In these diagrams, classes represent key elements and interactions within your application.

Code​

---
title: Animal example
---
classDiagram
note "From Duck till Zebra"
Animal <|-- Duck
note for Duck "can fly\ncan swim\ncan dive\ncan help in debugging"
Animal <|-- Fish
Animal <|-- Zebra
Animal : +int age
Animal : +String gender
Animal: +isMammal()
Animal: +mate()
class Duck{
+String beakColor
+swim()
+quack()
}
class Fish{
-int sizeInFeet
-canEat()
}
class Zebra{
+bool is_wild
+run()
}

Example​