Class Diagrams
Class diagrams show the structure of a system by depicting classes, their attributes, methods, and relationships.
Basic Class
E-commerce System
Design Patterns
Factory Pattern
Observer Pattern
Error generating PlantUML diagram: Request failed with status code 520
@startuml
interface Observer {
+update(event: Event)
}
abstract class Subject {
-List<Observer> observers
+attach(observer: Observer)
+detach(observer: Observer)
+notify()
}
class ConcreteSubject extends Subject {
-String state
+getState(): String
+setState(state: String)
}
class ConcreteObserver implements Observer {
-String name
+update(event: Event)
}
Subject o--> Observer : notifies
ConcreteSubject --> ConcreteObserver
@enduml
Advanced Relationships
Error generating PlantUML diagram: Request failed with status code 520
@startuml
class School {
-String name
-String address
}
class Department {
-String name
-String code
}
class Professor {
-String name
-String employeeId
}
class Student {
-String name
-String studentId
}
class Course {
-String title
-String code
-int credits
}
' Composition: School "owns" departments
School "1" *-- "many" Department : has
' Aggregation: Department has professors
Department "1" o-- "many" Professor : employs
' Association: Professor teaches courses
Professor "1" -- "many" Course : teaches
' Many-to-many: Students enroll in courses
Student "many" -- "many" Course : enrolls
note right of School : Composition:\nDepartments cannot\nexist without School
note right of Department : Aggregation:\nProfessors can exist\nwithout Department
@enduml
Visibility Modifiers
+
Public-
Private#
Protected~
Package/Internal
Relationship Types
--|>
Inheritance..|>
Interface implementation--
Association-->
Directed associationo--
Aggregation*--
Composition..>
Dependency