Memra

Which diagram, and why

◈ 6 cards

Each notation answers exactly one question and is silent on the others; the marks — in the exam and in Assignment 4 — are for a justified selection, including a justified refusal.

Four notations, four questions

By this point you can produce four drawings of the same system, and the temptation is to produce all four for every use case. Resist it. Each notation exists to answer one question, and the professional move — the one Assignment 4 and the thinking problem both reward — is to name the question first and let it select the notation.

  • Activity diagram answers what happens next, in what order, and where does the flow branch? Its primitives are actions, flow, labelled decisions and forks.
  • Swim-lane diagram answers the same question plus who is responsible for each step? Its extra primitive is the lane, and its extra product is the visible hand-off.
  • Sequence diagram answers which objects exchange which events, in what order? Its primitives are lifelines, downward time and event arrows.
  • State diagram answers what may happen to this one object next, and under what condition? Its primitives are active states and transitions labelled event [guard] / action.

Notice that the four questions are genuinely different questions, not four levels of detail on one question. That is why the answer "draw them all" is not thorough but confused: it says you have not worked out what you are trying to find out.

What each one cannot show

The fastest way to justify a choice is to name what the alternatives are silent about. An activity diagram cannot say who does anything. A swim-lane diagram cannot say what is permitted — it draws the path taken, not the rule governing it. A sequence diagram cannot express a guard on an object's life, because a guard is a fact about one object across all its episodes, not about this episode. A state diagram cannot express collaboration, because it has only one object to draw. None of these are defects; they are the cost of a notation being precise about one thing.

Write this asymmetry into an exam answer and it does two jobs at once: it proves you know the notations, and it supplies the justification the question asked for.

A diagram has a cost

Every diagram is a work product. It has to be reviewed, kept consistent with the use case it came from, and updated when the requirement changes — and a stale diagram is worse than no diagram, because someone will believe it. The book's own guidance is to use activity diagrams at the analysis level only where the functionality is relatively complex; the same restraint applies to all four notations.

So the honest selection rule has two halves. Draw a diagram when the question it answers is one you cannot currently answer from the use case text. Decline to draw one when the text already answers it — and say so explicitly, because on Assignment 4 and in a design review an unstated omission looks like an oversight while a stated one looks like judgement.

Worked example — three BorrowBox use cases, three choices, one refusal

Collect a reserved tool involves four participants including an external device, and the question everyone is arguing about is ordering: does the service verify before or after the door opens? That is a sequence diagram — many collaborators, one ordered episode.

Return and inspect has one flow but three parties and two hand-offs, and the question is where responsibility passes. That is a swim-lane diagram; a plain activity diagram would draw the same six actions and hide the two interfaces.

The ToolCopy is a long-lived object with rules about what is allowed next — you may not collect against an expired hold, you may not re-shelve an unsafe copy. That is a state diagram, and no per-use-case drawing can hold those rules because they span every use case at once.

And the refusal: Cancel a reservation is three steps performed entirely by the ReservationService, with one guard already stated in the use case text. An activity diagram of it would have three boxes in a line; a swim-lane version would have one lane; a sequence diagram would have one lifeline sending nothing. All three are legal and all three are worthless, so the model does not include one — and the justification is a sentence, not a shrug: the only interesting fact about this use case is the guard, and the guard is already visible on the ToolCopy state diagram as the transition out of Reserved.

Question in, notation outThe question you areaskingNotationWhat it cannot showWhat happens next, andwhere does it branch?ActivityWho is responsible for anystepWho does each step, andwhere does work changehands?Swim-laneWhat is permitted, onlywhat was doneWhich objects exchangewhich events, in whatorder?SequenceA guard on one objectacross its lifeWhat may happen to thisobject next, and when?StateCollaboration — it has oneobject onlyNothing the use case texthas not already answeredNoneSay so, and say why — thatis the markName the question first; the notation follows from it.
The selection rule as a table. Read it left to right in a design review or an exam answer: name the question, choose the notation, then name what you have given up. The third column is where the justification marks live — it is the evidence you chose rather than defaulted.
NORMAL ~/memra/learn/comp-410/choosing-a-behavioural-diagram utf-8 LF