UML Diagrams
UML notation an analyst draws — the diagram taxonomy, class relationships and multiplicity, aggregation vs composition, state machines, use-case, activity and component diagrams.
12 questions
JuniorTheoryVery commonWhich relationships does a class diagram show, and how are association, generalization and dependency drawn?
Which relationships does a class diagram show, and how are association, generalization and dependency drawn?
A class diagram shows classes and their links: an association is a plain line (a lasting reference); generalization a hollow-triangle arrow meaning inheritance (is-a); a dependency a dashed arrow (transient use). Aggregation and composition are whole-part links.
Common mistakes
- ✗Mixing up the hollow-triangle (generalization) with an association arrowhead
- ✗Treating a dependency (transient use) as a lasting association
- ✗Forgetting that generalization means is-a inheritance, not whole-part
Follow-up questions
- →How does a dependency differ from an association in practice?
- →When would you show generalization instead of an association?
JuniorTheoryVery commonWhich elements does a use-case diagram have, and what do «include» and «extend» mean on it?
Which elements does a use-case diagram have, and what do «include» and «extend» mean on it?
A use-case diagram has actors (outside the system), use cases (ovals inside a boundary box) and relationships. «include» factors out a step the base case always runs; «extend» adds an optional conditional step. Generalization lets an actor or use case inherit another.
Common mistakes
- ✗Swapping «include» (always runs) with «extend» (conditional)
- ✗Placing actors inside the boundary box instead of outside it
- ✗Drawing the «extend» arrow in the wrong direction between cases
Follow-up questions
- →In which direction does the «extend» arrow point, and why?
- →When should a repeated step become an «include» rather than staying inline?
JuniorDesignCommonSketch the class model for an online bookstore. The domain has customers who place orders; each order lists one or more books; a book has an author and belongs to a catalogue category. Name the classes you would show, the relationship type between each pair (association, aggregation or composition), and the multiplicity on each end. Explain in particular whether order lines are a composition or an aggregation of the order, and how a book connects to its category and its author, so the model reads unambiguously to a developer.
Sketch the class model for an online bookstore. The domain has customers who place orders; each order lists one or more books; a book has an author and belongs to a catalogue category. Name the classes you would show, the relationship type between each pair (association, aggregation or composition), and the multiplicity on each end. Explain in particular whether order lines are a composition or an aggregation of the order, and how a book connects to its category and its author, so the model reads unambiguously to a developer.
Classes: Customer, Order, OrderLine, Book, Author, Category. Customer 1 — Order 0... Order 1 composes OrderLine 1.. (lines cannot exist without their order). OrderLine references Book 1. Book links to Category (0.. — 1) and Author (1.. — 1) by plain associations. Multiplicity on both ends.
Common mistakes
- ✗Making order lines an aggregation, so they survive their deleted order
- ✗Using inheritance where a plain association (Book–Author) belongs
- ✗Omitting multiplicity, leaving one-to-many links ambiguous
Follow-up questions
- →Why are order lines a composition but a book only an association?
- →How would you model a book having several co-authors?
JuniorTheoryCommonWhich UML diagram groups exist, and which of them does an analyst actually draw?
Which UML diagram groups exist, and which of them does an analyst actually draw?
UML diagrams split into two families: structural (class, component, deployment) show static make-up, and behavioral (use-case, activity, sequence, state machine) show behaviour over time. Analysts most often draw use-case, activity, sequence and class ones.
Common mistakes
- ✗Thinking every UML diagram is behavioral and structure is not modelled
- ✗Confusing the structural/behavioral split with a functional/non-functional one
- ✗Assuming analysts draw deployment diagrams rather than use-case and activity ones
Follow-up questions
- →Which behavioral diagram best fits a step-by-step scenario, and why?
- →Why do analysts rarely own deployment and component diagrams?
JuniorTheoryCommonOn a sequence diagram, what are the lifeline and activation bar, and how do synchronous and asynchronous messages differ?
On a sequence diagram, what are the lifeline and activation bar, and how do synchronous and asynchronous messages differ?
A lifeline is the dashed vertical under each participant, showing its existence over time; an activation bar marks when it is active. A synchronous message (filled arrowhead) blocks the caller until a reply returns; an asynchronous one (open arrowhead) is fire-and-forget.
Common mistakes
- ✗Confusing the lifeline (existence over time) with the header box
- ✗Swapping the meanings of synchronous (blocking) and asynchronous (fire-and-forget)
- ✗Ignoring the filled-versus-open arrowhead that signals the message kind
Follow-up questions
- →How do you show a reply to a synchronous message on the diagram?
- →How would you draw a timeout on an asynchronous call?
MiddleTheoryCommonHow do aggregation and composition differ, and what happens to the parts when the whole is deleted?
How do aggregation and composition differ, and what happens to the parts when the whole is deleted?
Both are whole-part associations differing in ownership. Aggregation (hollow diamond) is weak: parts exist independently and outlive the whole, surviving its deletion. Composition (filled diamond) is strong: each part belongs to one whole and is destroyed with it — a cascading delete.
Common mistakes
- ✗Swapping which one (composition) cascades the delete to its parts
- ✗Believing aggregation and composition are fully interchangeable
- ✗Confusing the whole-part diamond with the generalization triangle
Follow-up questions
- →Which of the two allows a part to be shared by several wholes?
- →How does composition map to a cascading foreign-key delete in a database?
MiddleTheoryCommonHow do you read multiplicity on a class diagram (1..*, 0..1), and how is a many-to-many link resolved?
How do you read multiplicity on a class diagram (1..*, 0..1), and how is a many-to-many link resolved?
Multiplicity at an end says how many objects of that class link to one at the other end — 1, 0..1, 1..*, *. A many-to-many link (* on both ends) is resolved with an association class, becoming two one-to-many links that hold the pairing's attributes.
Common mistakes
- ✗Reading
0..1and1..*as if their bounds were reversed - ✗Leaving a many-to-many link unresolved instead of adding an association class
- ✗Putting multiplicity on the class box rather than on the link end
Follow-up questions
- →Where would you store an attribute that belongs to the pairing itself?
- →How does an association class map to a database join table?
JuniorTheoryOccasionalWhat is an activity diagram, and how do you show a fork/join and a decision node on it?
What is an activity diagram, and how do you show a fork/join and a decision node on it?
An activity diagram models a workflow of actions from start to end. A decision node is a diamond branching on a guard, later rejoined at a merge node. A fork splits one flow into several parallel ones; a join waits for all of them and merges them into one.
Common mistakes
- ✗Confusing a fork/join (parallelism) with a decision/merge (branching)
- ✗Forgetting that a join waits for all parallel flows before proceeding
- ✗Mixing an activity diagram up with a sequence or class diagram
Follow-up questions
- →How does a merge node differ from a join node?
- →How would you use swimlanes to show who performs each action?
MiddleTheoryOccasionalHow does a UML class diagram differ from an ER (entity-relationship) diagram, and when do you draw each?
How does a UML class diagram differ from an ER (entity-relationship) diagram, and when do you draw each?
A class diagram models software objects — classes with attributes and behaviour (methods). An ER diagram models only stored data — entities, attributes and relationships, no behaviour. Use a class diagram for the object model, an ER diagram for the database schema.
Common mistakes
- ✗Thinking an ER diagram models behaviour/methods like a class diagram
- ✗Using a class diagram to design the database schema
- ✗Treating the two notations as fully interchangeable
Follow-up questions
- →Which diagram would you hand to a DBA, and why?
- →How does a class map onto an entity when the object model becomes tables?
MiddleTheoryOccasionalWhat is a UML component diagram, and what does it show that a deployment diagram does not?
What is a UML component diagram, and what does it show that a deployment diagram does not?
A component diagram shows the system's logical components and the interfaces each provides and requires — how the software is wired. A deployment diagram instead shows physical topology: hardware nodes and the artifacts on them. It captures logical structure, not runtime placement.
Common mistakes
- ✗Swapping component (logical) and deployment (physical) diagrams
- ✗Thinking a component diagram lists classes with fields and methods
- ✗Forgetting that components expose provided and required interfaces
Follow-up questions
- →What do the provided and required interface symbols mean?
- →When would you draw a deployment diagram instead?
MiddleDesignOccasionalA developer is joining your team and needs to understand how three microservices integrate — which service calls which, over which interfaces and protocols. You must pick a single UML diagram to draw for this. Name the diagram you would choose, justify why it fits this purpose better than a sequence diagram, a deployment diagram and a class diagram, and say what each of those three would emphasise instead — so it is clear you are choosing deliberately rather than by habit.
A developer is joining your team and needs to understand how three microservices integrate — which service calls which, over which interfaces and protocols. You must pick a single UML diagram to draw for this. Name the diagram you would choose, justify why it fits this purpose better than a sequence diagram, a deployment diagram and a class diagram, and say what each of those three would emphasise instead — so it is clear you are choosing deliberately rather than by habit.
Pick a component diagram: it draws each microservice as a component with its provided and required interfaces, making the integration wiring explicit. A sequence diagram shows only one scenario's messages; a deployment diagram physical nodes, not logical calls; a class diagram is too fine-grained here.
Common mistakes
- ✗Choosing a deployment diagram, which shows nodes not logical calls
- ✗Reaching for a class diagram, too fine-grained for service integration
- ✗Assuming a sequence diagram captures the whole integration, not one flow
Follow-up questions
- →When would a sequence diagram be the better choice instead?
- →How do provided and required interfaces show the integration protocol?
MiddleTheoryOccasionalWhat is a state-machine diagram, what does a transition need, and how do you model an order's statuses?
What is a state-machine diagram, what does a transition need, and how do you model an order's statuses?
A state-machine diagram models an object's lifecycle as states and transitions. A transition needs a source state, a target state and a triggering event, plus an optional guard and action. An order becomes states New, Paid, Shipped, Delivered, Cancelled, driven by events like «pay».
Common mistakes
- ✗Confusing a state-machine diagram with a class or sequence diagram
- ✗Thinking a transition needs no triggering event
- ✗Treating the guard as mandatory and the event as optional
Follow-up questions
- →How would you show a guard condition on a transition?
- →What is the difference between an initial state and a final state?