UML is divided into two main categories: Structural Diagrams (how the system looks) and Behavioral Diagrams (how the system acts).
🏗️ Structural Diagrams
These represent the static parts of the system—the "skeleton."
1. Class Diagram
The most common UML diagram. It describes the structure of a system by showing its classes, their attributes, operations, and the relationships among objects.
Shows: Inheritance, aggregation, and associations.
Analogy: The floor plan of a house.
2. Component Diagram
Describes how the system is split into physical components and the dependencies between them.
Shows: High-level organization of code libraries and modules.
3. Deployment Diagram
Shows the physical hardware on which the software will be installed (nodes) and how they are connected.
Shows: Servers, networks, and devices.
🎬 Behavioral Diagrams
These represent the dynamic parts of the system—the "motion."
1. Use Case Diagram
Visualizes the functional requirements from a user's perspective.
Shows: Who (Actors) does what (Use Cases).
2. Sequence Diagram
A Time-Ordered diagram that shows how objects interact with each other in a specific scenario.
Shows: The exchange of messages between objects over time.
Analogy: A movie script showing who speaks to whom and when.
3. State Machine Diagram (Statechart)
Shows the different states an object can be in and the events that cause it to change from one state to another.
Example: An Order can be in states:
Pending→Paid→Shipped→Delivered.
4. Activity Diagram
Basically a fancy flowchart. It shows the flow of control from one activity to another.
Shows: Logic, decision points (if/else), and parallel processing.
📊 Summary: Which Diagram to Use?
If you want to show... | Use this Diagram: |
|---|---|
Object relationships & data structure | Class Diagram |
Step-by-step logic/workflow | Activity Diagram |
Message timing between objects | Sequence Diagram |
User interactions with the system | Use Case Diagram |
Hardware setup and servers | Deployment Diagram |
💡 Why bother with UML?
Complexity Management: It's easier to find a flaw in a drawing than in 10,000 lines of code.
Language Independent: A Class Diagram is the same whether you code in Java, Python, or C++.
Documentation: New developers can look at a UML diagram and understand the system architecture in minutes.