skip to content

UML

UML gives teams a shared notation for structure and behaviour — class, sequence, use-case, activity, and state diagrams. Interviewers rarely demand perfect syntax, but they do expect you to sketch a design someone else can read.

on this pageshow

explore

questions

25

In a UML activity diagram, what is the difference between a decision node and a fork node?

level: juniorimportance: must knowfreq 74%

answer

  1. Ask how many paths continue
  2. Choice of one, or all at once
  3. Diamond splits by guard, bar splits unconditionally
  4. Merge closes alternatives; join closes concurrency

basics

~20 s

A decision node chooses exactly one outgoing path, selected by guards on its edges; a fork node starts every outgoing path at once as concurrent flows. A merge node reunites the alternatives; a join node waits for all the concurrent flows.

solid answer

~50 s

Both symbols split a flow, but into different things. A **decision node** is a diamond with one incoming edge and several outgoing edges, each carrying a guard in square brackets; exactly one of those edges is taken. A **fork node** is a thick bar that copies the incoming token onto *every* outgoing edge, so all of those flows become active together — it is concurrency, and its edges carry no guards. Each has a closing partner, and the pairing is what interviewers are really testing: alternatives opened by a decision node close with a **merge node**, which passes each arriving token straight through; concurrency opened by a fork node closes with a **join node**, which waits until a token has arrived on every incoming edge. Read the edge counts before the shape, because both diamonds look alike and both bars look alike.

code

pseudocode · 15 lines
pseudocode
initial -> receive request
receive request -> DIAMOND
DIAMOND -[urgent]-> triage now
DIAMOND -[else]-> queue for later
triage now -> MERGE-DIAMOND
queue for later -> MERGE-DIAMOND
MERGE-DIAMOND -> record outcome

record outcome -> BAR-SPLIT
BAR-SPLIT -> notify requester
BAR-SPLIT -> update record
notify requester -> BAR-SYNC
update record -> BAR-SYNC
BAR-SYNC -> close request
close request -> activity final

go deeper

for a junior

Be ready to name all four nodes on sight: a diamond is a decision or a merge, a thick bar is a fork or a join. Say plainly which one picks a single path and which one starts several at once.

for a middle

Explain the token rule for each node — one outgoing edge for a decision, a copy on every edge for a fork, straight through for a merge, wait-for-all for a join — and show which node pairs with which when the paths come back together.

for a senior

Show that you catch the two structural bugs in review: alternatives closed by a join node, which stalls the flow, and concurrency closed by a merge node, which runs the following action twice on partial results.

for a principal

Own the convention for the team. Decide when concurrency belongs in a model at all, because a fork node the implementation cannot honour buys nothing and misleads every later reader of the diagram.

## Tokens: the rule behind every node An activity diagram models work as **actions joined by control flows**, and the way to read one is as a token game. An *initial node* drops a token into the flow; each **action** takes the token, performs its step, and puts it back on its outgoing edge; the token travels along the edges until a final node absorbs it. Every node type is nothing more than a rule about what it does with the tokens that arrive on it, and the four nodes people confuse differ only in that rule. A **decision node** is a diamond with one incoming edge and two or more outgoing edges. Each outgoing edge carries a **guard** written in square brackets. Exactly one outgoing edge is taken — the one whose guard is true — so a decision node is a *choice of one path*. A **merge node** is also a diamond, but with several incoming edges and one outgoing edge. It passes every arriving token straight through and waits for nothing. It is what you draw to bring alternative paths back together. A **fork node** is a thick bar with one incoming edge and several outgoing edges. It copies the token onto **every** outgoing edge, so all those flows become active at the same time. A fork node is *concurrency*, and its outgoing edges carry no guards. A **join node** is the same thick bar with several incoming edges and one outgoing edge. It waits until a token has arrived on every incoming edge, then emits a single token. It is the synchronisation partner of a fork node. ## The pairing rule | Node | Shape | Edges | Rule for arriving tokens | Closing partner | |---|---|---|---|---| | Decision | Diamond | 1 in, many out | leaves by the single edge whose guard is true | Merge | | Merge | Diamond | many in, 1 out | each token passes straight through, no waiting | Decision | | Fork | Bar | 1 in, many out | copied onto every outgoing edge at once | Join | | Join | Bar | many in, 1 out | held until every incoming edge has a token | Fork | The pairing is the whole trick: **a decision node closes with a merge node, a fork node closes with a join node**. Two shapes carry four meanings, so read the *edge count and direction* before you read the shape. One edge in and many out is a split — a choice if it is a diamond, concurrency if it is a bar. Many edges in and one out is a rejoin — pass-through if a diamond, wait-for-all if a bar. Some diagrams draw a single diamond with several incoming and several outgoing edges; read that as a merge immediately followed by a decision. ## The two failures interviewers listen for 1. **Closing alternatives with a join node.** The decision node sent the token down one of two paths, so only one incoming edge of the join will ever carry a token. The join waits for the other one forever and the flow stalls. On a whiteboard it looks tidy and symmetric, which is exactly why it survives review. 2. **Closing concurrency with a merge node.** A fork node put a token on both paths, and the merge passes each one through as it arrives, so the action after the merge runs **twice** — once early, on partial results. In a real workflow this is the duplicate notification, or the record written before half its content exists. A third, quieter mistake is hanging a guard on a fork node's outgoing edge. If a path is conditional it is a choice, and the honest model puts a decision node before or after the fork rather than smuggling a condition onto a concurrency bar. ## Concurrency here means 'unordered', not 'threaded' A fork node does not claim that the paths run on separate threads, processors or machines. It claims something weaker and far more useful: **the diagram places no ordering constraint between those flows**. They may interleave, run genuinely in parallel, or run one after the other — every one of those is a legal execution of the model. Draw a fork when the order truly does not matter, and a plain sequence when it does. A fork over work that must be ordered is a modelling error even if the implementation happens to serialise it anyway. ## A reading checklist - Count edges first: one-in-many-out is a split, many-in-one-out is a rejoin. - Diamond means choice or pass-through; bar means concurrency or synchronisation. - Every outgoing edge of a diamond split should carry a guard, including a catch-all. - No outgoing edge of a bar split carries a guard. - Trace one token by hand: it should reach exactly one outcome, and nothing after a rejoin should be reachable twice. - If a join node has an incoming edge that a token cannot always reach, you have drawn a deadlock. The pay-off for getting this right is that the diagram becomes executable in a reader's head. A colleague can put a finger on the initial node, walk the token, and find the duplicate run or the stall before anybody writes the code — which is the only reason to draw the picture at all.

  • What happens if a join node is used where a merge node belongs?
    The join node waits for a token on every incoming edge, but the decision node upstream only ever produced one, so the other edge stays empty and the flow stalls at the bar forever. It is a modelled deadlock, and it reads as symmetric and tidy on the page, which is why it survives review. Alternatives always close with a merge node.
  • Can the outgoing edges of a fork node carry guards?
    No — a fork node starts every outgoing flow unconditionally, and that is the entire content of the symbol. If one of the concurrent paths is conditional, model it honestly: put a decision node on that path after the fork, or before the fork when the condition decides whether concurrency starts at all.
  • Does a fork node mean the flows run on separate threads?
    No. A fork node asserts only that the diagram places no ordering constraint between those flows, so interleaved, truly parallel and strictly sequential are all legal executions of the same model. Use one when order genuinely does not matter; an implementation that serialises forked flows is not violating the diagram.

A decision node is a railway switch: the train leaves on exactly one track. A fork node is a shunting yard that sends a copy of the train down every track at once, and the join node further along is the platform that will not dispatch until all the copies are back.

saying these in an interview costs you the question

  • Calls every diamond a fork because both split the flow
  • Thinks a fork node evaluates a condition before splitting
  • Uses a join node to reunite mutually exclusive alternative paths
  • Uses a merge node to reunite two concurrent flows
  • Insists a fork node requires separate threads to be valid
  • Writes the guard inside the diamond instead of on its edges
open as a page

In a UML class diagram, how do you read a class box's three compartments and its visibility markers?

level: juniorimportance: must knowfreq 74%

basics

~20 s

A class box stacks three compartments: the class name on top, the attributes in the middle, the operations at the bottom. A leading +, -, # or ~ on a member marks it public, private, protected or package-visible.

open as a page

In a UML sequence diagram, what does a lifeline represent and what does its activation bar show?

level: juniorimportance: must knowfreq 68%

basics

~20 s

A lifeline is one participant in the interaction — an object, component or actor — drawn as a labelled box above a dashed vertical line down which time runs. The activation bar marks the stretch where that participant is actively executing.

open as a page

In a UML state machine diagram, what do a state, an event and a transition each represent?

level: juniorimportance: must knowfreq 78%

basics

~20 s

A state is a named condition the object waits in over time. An event is a discrete occurrence the object perceives. A transition is the arc that fires when that event arrives and moves the object from one state to another.

open as a page

What is the difference between structural and behavioural UML diagrams?

level: juniorimportance: must knowfreq 74%

basics

~20 s

Structural UML diagrams show what a system is made of — its parts and how they are arranged, frozen in time. Behavioural UML diagrams show what it does — how the parts act, react and change as time passes.

open as a page

In a UML use-case diagram, what does the system boundary assert, and what counts as an actor?

level: juniorimportance: must knowfreq 68%

basics

~20 s

The system boundary separates what you are building from everything outside it: use cases sit inside, actors outside. An actor is any external role that interacts with the system — a person, another system, or a scheduled trigger.

open as a page

In a UML class diagram, how do line styles and arrowheads distinguish generalization, realization, association and dependency?

level: middleimportance: must knowfreq 66%

basics

~20 s

Generalization is a solid line with a hollow triangle pointing at the more general class. Realization uses the same triangle on a dashed line. A plain association is a solid line; a dependency is a dashed line with a thin open arrowhead.

open as a page

How do a synchronous call, an asynchronous send and a reply differ in a UML sequence diagram?

level: middleimportance: must knowfreq 60%

basics

~20 s

A synchronous call is a solid line with a filled arrowhead and the sender waits. An asynchronous send is a solid line with an open stick arrowhead and the sender continues. A reply is a dashed line with an open arrowhead.

open as a page

In a UML state machine, when does behaviour belong on a state's entry action rather than on each incoming transition?

level: middleimportance: must knowfreq 58%

basics

~20 s

Behaviour belongs on the entry action whenever every way into the state must run it. A transition effect covers one path only, so work duplicated across several incoming arcs is exactly what an entry action replaces.

open as a page

How do you choose which UML diagram to draw for a given modelling question?

level: middleimportance: must knowfreq 56%

basics

~20 s

Start from the question, not the notation. Say in one sentence what you need to know — what the parts are, in what order they interact, or what one object's lifecycle permits — then draw the family that answers it.

open as a page

In a UML use-case diagram, how do include and extend differ, and which way does each arrow point?

level: middleimportance: must knowfreq 74%

basics

~20 s

Include means the base use case always performs the included behaviour, and the arrow points from base to included. Extend means optional behaviour attaches at a named extension point under a condition, with the arrow pointing from the extending use case to the base.

open as a page

In a UML activity diagram, why must a decision node's outgoing guards cover every case?

level: middleimportance: should knowfreq 51%

basics

~20 s

A decision node routes the arriving token down the single outgoing edge whose guard is true. If no guard holds, the token stops there and the path dies silently; if two hold, the model permits either path and no longer has one meaning.

open as a page

In a UML class diagram, what does the multiplicity at each end of an association tell you?

level: middleimportance: should knowfreq 58%

basics

~20 s

Multiplicity at an association end says how many objects of that end's class may be linked to one object at the far end. It is a range: 0..1 optional, 1 exactly one, 1..* one or more, * any number.

open as a page

What do the alt, opt and loop combined fragments express in a UML sequence diagram?

level: middleimportance: should knowfreq 46%

basics

~20 s

A combined fragment is a labelled box drawn over part of a sequence diagram, with an operator in its top-left pentagon. alt holds several guarded, mutually exclusive operands; opt holds one that runs only if its guard holds; loop repeats its operand.

open as a page

In a UML state machine diagram, what does a transition out of a composite state do to its active substates?

level: middleimportance: should knowfreq 50%

basics

~20 s

It exits them. Leaving a composite state first exits whichever substate is currently active, running that substate's exit action, then runs the composite's own exit action — so one arc drawn on the boundary covers every substate inside it.

open as a page

How does partitioning a UML activity diagram by responsibility expose where a cross-team approval workflow stalls?

level: seniorimportance: should knowfreq 41%

basics

~20 s

Partitions assign every action to the party that performs it, so each control flow that crosses a partition boundary is a handoff. Counting and timing those crossings shows where work waits, rather than where it is being worked on.

open as a page

What can a UML sequence diagram not show, and when does adding every call make it useless?

level: seniorimportance: should knowfreq 36%

basics

~20 s

A sequence diagram shows one ordered trace of one scenario. It cannot assert completeness, structure, data shape, real elapsed time, or what holds when nobody is calling. Transcribing every call produces a diagram that is unreadable and wrong within a sprint.

open as a page

When is a UML state machine the right way to model an object's lifecycle instead of a status field?

level: seniorimportance: should knowfreq 44%

basics

~20 s

Model explicitly when an object has several named conditions, when the legal moves between them matter, and when the same rules are being re-checked in scattered places. Two or three values with no ordering rules need no diagram at all.

open as a page

A team documents each feature with UML interaction diagrams alone. Which modelling questions does that leave unanswered?

level: seniorimportance: should knowfreq 32%

basics

~20 s

Interaction diagrams answer one scenario at a time, so everything that quantifies over all scenarios is missing: the type-level rules and multiplicities, which lifecycle transitions are legal, what the full set of user goals is, and what is co-located.

open as a page

A payroll platform's use-case diagram has grown to 31 tiny use cases that read like a function list — how do you diagnose and fix it?

level: seniorimportance: should knowfreq 38%

basics

~20 s

The diagram has slid into functional decomposition: those are steps, not goals. Test each entry by asking whether a primary actor would walk away satisfied when it completed, then collapse the steps into the handful of goals that pass and push the rest into the written flows.

open as a page

How do you decide how much of the UML diagram taxonomy a team should actually use?

level: principalimportance: should knowfreq 38%

basics

~20 s

Buy modelling where ambiguity is concentrated and expensive, rather than working through the taxonomy. Most teams need two or three families. Draw in answer to an open question, treat most diagrams as sketches, and keep only what is costly to rediscover.

open as a page

In a UML activity diagram, how does a flow final node differ from an activity final node?

level: middleimportance: nice to knowfreq 19%

basics

~20 s

An activity final node ends the whole activity: reaching it stops every flow still running. A flow final node ends only the one flow that arrives at it, and any concurrent flows carry on unaffected.

open as a page

In a UML state machine, what is the difference between a shallow and a deep history pseudo-state?

level: middleimportance: nice to knowfreq 18%

basics

~20 s

Shallow history remembers only which substate of its own region was last active. Deep history remembers the active configuration all the way down through every level of nesting. Both restore that memory when the composite state is re-entered.

open as a page

In a UML use-case diagram, what does generalization mean between two actors, and between two use cases?

level: middleimportance: nice to knowfreq 20%

basics

~20 s

Generalization is a solid line with a hollow triangle pointing at the more general element. A specialised actor can participate in everything the general actor can, plus its own; a specialised use case is a complete variant that can substitute for the general one.

open as a page

When does a UML class diagram earn its keep, and when is reading the code faster?

level: seniorimportance: nice to knowfreq 31%

basics

~20 s

A class diagram earns its keep when the shape is spread across many files or does not exist yet, and when a reader outside the code must follow it. Reading the source is faster whenever the diagram would restate one file.

open as a page