Class Diagram
About
A Class Diagram is a structural UML (Unified Modeling Language) diagram that visually represents the blueprint of a system's classes, their attributes, methods, and relationships. It is widely used in object-oriented programming to design and document system architecture.
Refer to the official documentation for more details - https://plantuml.com/class-diagram
Elements of a Class Diagram
Classes
Represented as a rectangle with three sections:
Class Name (e.g.,
Customer)Attributes (e.g.,
+name: String)Methods (e.g.,
+getCustomerDetails(): String)
Example:
+-----------------+ | Customer | +-----------------+ | - id: int | | - name: String | | - email: String | +-----------------+ | +getDetails() | | +updateEmail() | +-----------------+
Relationships
Defines how classes interact with each other.
Association (
--): Direct connection between classes.Aggregation (
<>--): A whole-part relationship where the part can exist independently.Composition (
*--): A stronger form of aggregation; the part cannot exist independently.Inheritance (
<|--): Denotes that one class is a subtype of another.Dependency (
..>): A weak relationship where one class depends on another.
Modifiers
Public (
+): Accessible from anywhere.Private (
-): Accessible only within the class.Protected (
#): Accessible within the class and its subclasses.Package (
~): Accessible within the same package.
1. Banking System
This diagram represents a Banking System, including multiple relationships such as inheritance, composition, aggregation, and dependencies.
Inheritance (
<|--):SavingsAccountandCurrentAccountinherit fromAccount.Association (
--):Customerowns multipleAccounts.Composition (
o--):Bankis composed of multipleAccounts.Multiplicity (
0..*,1): Defines relationships between classes.

2. Hospital Management System
This represents relationships between classes in a Hospital Management System.

Last updated