đź“…Day 4 - Understanding UML Diagrams: Real Examples of Class and Sequence Diagrams

Table of contents
- 1.) What is UML and why it’s used in Software Design?
- đź’ UML Diagram Parts: Structural & Behavioral
- 2.) How to draw and understand Class Diagrams (with real-world examples)
- 3) How to create and analyze Sequence Diagrams to visualize system interactions
- 4. ) How UML helps in real-life Low-Level Design and interview discussions

NOTE: - I started my 8-week system design journey with Coder Army. I will be journaling every day, recording what I learn, reflecting on it, and sharing it with my network to help newcomers to system design.
1.) What is UML and why it’s used in Software Design?
đź’ What is UML (Unified Modeling Language)?
UML stands for Unified Modeling Language – a standard way to visually represent the design of a system.
(Hindi: UML ka matlab hai ek aisa standardized diagram jisse hum software system ke design ko visual form mein dikhate hain.)
- Imagine UML as the blueprint of a house, but for software systems.
📍 Real-life analogy:
Before building a house, an architect creates floor plans and designs. Similarly, in software, developers create UML diagrams before writing code – so that the team understands what they’re building.
đź’ Why is UML important in Software Design?
Helps visualize the structure and flow of a system
Makes team collaboration easier
Simplifies problem-solving and planning
Used in Low-Level Design (LLD) to build scalable, clean systems
📍Real example:
Suppose you’re building a food delivery app like Zomato. UML will help you design how:
Users place orders 🍔
Restaurants receive them 🍽️
Delivery partners pick them up 🛵
Payments are handled đź’ł
đź’ UML Diagram Parts: Structural & Behavioral
UML diagrams are mainly divided into two parts:
1) Structural (Static) Diagrams
These diagrams represent the structure of a system — what things exist and how they’re related.
(Hindi: Structural ya static diagrams system ke parts aur unke relationships ko dikhate hain — jaise ek skeleton ya blueprint.)
They focus on what the system is.
2) Behavioral (Dynamic) Diagrams
These diagrams represent interactions and how things behave over time.
(Hindi: Behavioral ya dynamic diagrams system ke components ke beech hone wali activity ko dikhate hain.)
They focus on what the system does.
📍Why These Are Useful?
Better understanding of system structure & flow
Team collaboration made easy
Easy debugging and system maintenance
Foundation for real-world coding
đź’ 7 Types of Structural (Static) Diagrams
Class Diagram – Most commonly used
Object Diagram
Component Diagram
Deployment Diagram
Composite Structure Diagram
Package Diagram
Profile Diagram
🎯 Most Used: Class Diagram
📍 Real-life Example:
In an e-commerce app like Amazon:
You’ll have a User class, Product class, Order class
These classes connect to show how users place orders, view products, and make payments.
đź’ 7 Types of Behavioral (Dynamic) Diagrams
Sequence Diagram – Most commonly used
Use Case Diagram
Activity Diagram
Communication Diagram
State Machine Diagram
Timing Diagram
Interaction Overview Diagram
🎯 Most Used: Sequence Diagram
📍 Real-life Example:
In a food delivery app:
A user places an order
The restaurant gets the order
The delivery partner picks it up
Payment confirmation is sent
The Sequence Diagram shows how this flow happens step by step over time.
2.) How to draw and understand Class Diagrams (with real-world examples)
đź’ What is a Class Structure?
Class diagrams show the main entities (classes) of the system, their attributes, and the connections between them.
(Hindi : Class Diagram system ke main entities (classes), unke attributes aur unke beech ke connections ko show karta hai.)
📍 Real-world example:
Class: Car
Attributes: brand
, model
, engine
Methods: startEngine()
, brake()
class Car {
String brand;
String model;
void startEngine() { ... }
}
Visibility Notation:
+
for public (visible to all classes)-
for private (visible only within the class)#
for protected (visible to subclasses)~
for package or default visibility (visible to classes in the same package)
đź’ What is an Association / Connection?
An association represents a bi-directional relationship between two classes. It means instances of one class are connected or linked to instances of another class.
(Hindi : Association ek bi-directional relationship hoti hai do classes ke beech. Iska matlab hai ki ek class ke instances doosri class ke instances se connected ya linked hote hain.)
Association types :
Class Association : a) Inheritance
Object Association : a) Simple Association , b) Aggregation, c) Composition
Depicted as: A solid line connecting two class boxes in UML.
Optional arrows can indicate direction (one-way or two-way).
📍 Real-world example:
Class 1:
Library
Class 2:
Book
The
Library
class has a collection ofBook
objects.Library
is the source class (has a reference to books).
Book
is the target class (belongs to a specific library).public class Library { private List<Book> books; } public class Book { private String title; }
đź’ Inheritance
Represents: "is-a" relationship
Arrow: Solid line with empty arrowhead pointing to the parent (
--â–·
)
Example: Dog
is an Animal
class A {
void method1() {
System.out.println("A");
}
}
class B extends A {
void method2() {
System.out.println("B");
}
}
public class Main {
public static void main(String[] args) {
B b = new B();
b.method1(); // from A
b.method2(); // from B
}
}
đź’ Simple Association
Represents: "uses-a" or "has-a" relationship (loose connection)
Arrow: Solid line (→) or solid line with optional direction (no triangle for simple association)
Example:
Arjun → House
(Arjun lives in a house)
đź’ Aggregation
Represents: "has-a" but loosely bound
Arrow: Empty diamond arrow (
<>---
)Example:
Sofa <>--- Room
,Chair <>--- Room
(Room can exist even if sofa/chair is removed)
đź’ Composition
Represents: Strong containment
Arrow: Filled diamond arrow (
<~>---
)
Example:Wheel <~> Chair
, Arms <~> Chair
(Without chair, its parts don't exist)
class A {
void method1() {
System.out.println("From A");
}
}
class B {
A a;
B() {
a = new A(); // Strong containment (composition)
}
void method2() {
System.out.println("From B");
}
}
public class Main {
public static void main(String[] args) {
B b = new B();
b.method2(); // From B
b.a.method1(); // From A (through composition)
}
}
3) How to create and analyze Sequence Diagrams to visualize system interactions
A sequence diagram is a behavioral UML diagram that shows the interactions between different objects in a time sequence.
(Hindi : Sequence Diagram ek Behavioral UML Diagram hai jo different objects ke beech mein hone wali interactions ko time ke order mein dikhata hai.)
📍Use When:
When you want to model how different components interact in a specific use case.
đź’ Main Components of a Sequence Diagram:
Objects / Classes
Example: A, B, C, D (entities involved)Lifeline
When the object is active in the systemActivation Bar
The time period till which the object is active (send/receive messages)Messages
Synchronous: Sender waits for response
Asynchronous: Sender does not wait for response
đź’ Special messages:
Create message: When an object is created
Destroy message: When an object is destroyed
Lost message: Message was sent but not received
Found message: Message was received but not known who sent it
User -> App: Request Ride
App -> Server: Check Availability
Server -> Driver: Send Request
Driver -> App: Accept Ride
App -> User: Ride Confirmed
4. ) How UML helps in real-life Low-Level Design and interview discussions
UML (Unified Modeling Language) is like a visual blueprint for software design. It helps you explain and plan systems clearly, especially during coding and interviews. Here’s why it matters:
Clear Visuals
UML diagrams (like class and sequence diagrams) break down complex systems into simple parts, making it easy for everyone to understand.Shows Relationships
It clearly represents key relationships like inheritance (is-a), aggregation (has-a), and composition (strong has-a), which helps build solid designs.Makes Coding Easier
With UML, you know what to build and how parts connect, reducing guesswork and speeding up development.Impresses Interviewers
Using UML in interviews shows you think systematically, understand OOP principles, and can communicate complex ideas clearly.Bridges Teams
UML helps developers and non-technical stakeholders (like product managers) stay on the same page.
User ATM Account Transaction CashDispenser
| | | | |
|--insertCard()->| | | |
|--enterPIN()--->| | | |
| |--validatePin->| | |
| |<--valid/invalid--| | |
|--selectWithdraw(amount)------->| | |
| |--createTxn()------------------->| |
| | |--initiate()-->| |
| |<----------------|<--complete()---| |
| |--debit()------->| | |
| |<--success--------| | |
| |--dispenseCash()------------------------------->|
| |<------------------cash dispensed---------------|
|<--Take cash--------------------| | |
📍 Diagram
Day 4 Completed âś… System Design
NOTE : - A big thanks to my mentors Rohit Negi Sir and Aditya Sir for launching this amazing 8-week course absolutely free on YouTube via CoderArmy9 :- https://www.youtube.com/@CoderArmy9🙌
👉 Share this blog with your connections! Let’s keep learning, growing, and supporting one another on this journey. 🚀
✍️ Payal Kumari 👩‍💻
Jai Hind 🇮🇳 | #CoderArmy #LearningInPublic #SystemDesign #TechForAll #MentorshipMatters #8weeksLLdChallenge #LowLevelDesign #Code #LLD #OOP #UMLDiagrams 👩‍💻
Subscribe to my newsletter
Read articles from Payal Kumari directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Payal Kumari
Payal Kumari
I'm a passionate full-stack developer with a strong foundation in the MERN stack—building and maintaining scalable web applications using React.js, Node.js, and Next.js. My journey in open source began with Hacktoberfest 2023, where I made four impactful pull requests that sparked a love for collaborative coding, global learning, and open knowledge sharing. Since then, I’ve contributed to and mentored projects in top open source programs like GSSoC’24, SSOC’24, and C4GT’24. As a Google Gen AI Exchange Hackathon ’24 Finalist and Google’s Women Techmakers (WTM) Ambassador, I’ve been privileged to support diverse communities in building meaningful tech solutions. My work as a Top 50 Mentor for GSSoC ’24 reflects my commitment to nurturing new talent in tech. Beyond development, I serve as a Student Career Guide, Profile Building Expert & Evangelist at Topmate.io, where I conduct workshops, guide students through resume building and career strategy, and help mentees navigate open source and tech careers. Recognized among the Top 5% of mentors and featured on “Topmate Discover,” I take pride in making mentorship accessible and impactful. My technical voice has also been acknowledged by LinkedIn, where I’ve earned the Top Voice badge seven times in domains like web development, programming, and software engineering. In addition, I hold LinkedIn Golden Badges for Research Skills, Interpersonal Skills, Critical Thinking, and Teamwork—signaling a well-rounded approach to both individual contribution and team collaboration. Graduating with an MCA from Chandigarh University in 2023, I’ve continued to fuel my curiosity by writing technical articles and sharing practical MERN stack insights across platforms. Whether it’s building polished UIs, optimizing backend performance, or guiding a mentee through their first pull request, I’m driven by the power of community and continuous learning. Let’s connect! I'm open to collaborations, mentorship, or building something impactful together. Reach out to me at kumaripayal7488@gmail.com or visit my profile on Topmate.io.