4.5.4Software Engineering

UML — use case, class, sequence, activity, state machine, component diagrams

2,674 words12 min readdifficulty · medium

The two grand families


1. Use Case Diagram


2. Class Diagram


3. Sequence Diagram


4. Activity Diagram


5. State Machine Diagram


6. Component Diagram


Recall Feynman: explain to a 12-year-old

Imagine you're building a giant LEGO theme park.

  • Use case = the poster listing what visitors can do ("ride coaster", "buy ticket").
  • Class = the parts catalogue: what bricks exist and which clicks onto which.
  • Sequence = a comic strip showing, step by step, who hands what to whom and in what order.
  • Activity = the route map of the workflow, with forks where two things happen at once.
  • State machine = the moods of one robot: locked, unlocked — and what button flips it.
  • Component = the big boxes the park ships in, each with plugs (sockets) that snap together. Same park, six different drawings, each answering a different question.

Flashcards

What question does a Use Case diagram answer?
WHO (actors) can do WHAT (goals) with the system — requirement-level functionality.
Difference between <<include>> and <<extend>>?
include = mandatory, always-used sub-behaviour (base depends on it); extend = optional, conditional add-on.
Aggregation vs Composition — the deciding test?
"If the whole is deleted, must the part die?" Yes → composition (filled ◆); No → aggregation (hollow ◇).
In a class diagram, what do +, -, # mean?
+ public, - private, # protected (visibility of members).
What does a sequence diagram put on its two axes?
Objects spread across (X); time flows downward (Y).
Lifeline vs activation bar in a sequence diagram?
Lifeline (dashed) = object exists; activation bar = object is actively executing a method.
Decision node vs Fork in an activity diagram?
Decision (◇) picks exactly ONE guarded branch; Fork (━) starts ALL branches in parallel.
What does a Join (━) do in an activity diagram?
Synchronizes parallel flows — waits until all incoming flows complete before continuing.
A transition label in a state machine has what 3 parts?
event [guard] / action — trigger, condition, side-effect.
State (state machine) vs Action (activity) — key difference?
State = a condition you sit in until an event arrives; Action = a step you do then immediately leave.
What is a "lollipop" vs a "socket" in a component diagram?
Lollipop (──○) = provided interface (offered); socket (──◗) = required interface (needed).
Which UML diagrams are structural vs behavioural?
Structural: Class, Component. Behavioural: Use Case, Sequence, Activity, State Machine.

Connections

  • Object-Oriented Programming — class diagrams ↔ classes, inheritance, encapsulation.
  • Design Patterns — often communicated via class & sequence diagrams.
  • Requirements Engineering — use case diagrams capture functional requirements.
  • Software Architecture — component diagrams describe modular architecture.
  • Finite State Machines — theoretical basis of state machine diagrams.
  • Flowcharts — activity diagrams are their richer cousin (forks, swimlanes).
  • SOLID Principles — "program to an interface" appears literally in component diagrams.

Concept Map

splits into

splits into

includes

includes

includes

includes

includes

includes

has

has

include = depends always

extend = optional

UML shared visual vocabulary

Structural static

Behavioural dynamic

Class diagram

Component diagram

Use Case diagram

Sequence diagram

Activity diagram

State Machine diagram

Actor role outside

include vs extend

base needs sub-behaviour

extension reaches into base

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, sabse pehle basic baat samajh lo — software ek invisible cheez hai. Jaise ek bridge ko tum apni aankhon se dekh sakte ho, waise software ko nahi dekh sakte. Isiliye UML banaya gaya — ye ek visual language hai jisse clients, developers aur testers sabhi ek hi picture dekh kar system ke baare mein baat kar sakein. Aur sabse important intuition ye hai ki ek complex system ke kai alag-alag viewpoints hote hain, aur koi ek diagram sab kuch capture nahi kar sakta. Isiliye UML ek family of diagrams hai — har diagram ek alag sawaal ka jawaab deta hai: kaun use karta hai (Use Case), kya cheezein exist karti hain (Class), messages kis order mein aate hain (Sequence), workflow kaise flow karta hai (Activity), waghera.

Ab ek badi picture ye hai ki saare diagrams do families mein bat jaate hain — Structural aur Behavioural. Structural diagrams system ki static shape batate hain, matlab kya-kya exist karta hai (jaise Class aur Component). Behavioural diagrams batate hain ki system chalte waqt time ke saath kya hota hai (jaise Sequence, Activity, State Machine). Ye split kyun matter karta hai? Kyunki jab tum debug karte ho, structure ka problem alag hota hai aur flow ka problem alag. Kaunsa diagram banana hai ye decide karna hi aadhi skill hai, isliye ye distinction dimaag mein rakhna zaroori hai.

Do cheezein specially yaad rakhna. Use Case diagram mein <<include>> aur <<extend>> students ko confuse karte hain kyunki dono dotted arrows lagte hain. Trick simple hai — incluDe matlab Depends always (jaise ATM mein Withdraw Cash hamesha Authenticate karega), aur eXtend matlab eXtra ya optional (jaise Print Receipt tabhi hoga jab user chahe). Aur Class diagram mein relationships ki strength badhti jaati hai — Association sabse weak "knows about", phir Aggregation "has-a" jahan parts independently jee sakte hain, phir Composition "owns-a" jahan parts whole ke saath hi mar jaate hain (jaise House aur Room), aur Inheritance "is-a" (Dog is-a Animal). Ye samajhna important hai kyunki ye directly tumhare actual OOP code se map hota hai.

Go deeper — visual, from zero

Test yourself — Software Engineering

Connections