Archyno
UMLZáklady

Ktorý UML diagram použiť

Všetkých štrnásť typov UML diagramov vedľa seba, zoradených podľa otázky, na ktorú odpovedajú - aby ste si vybrali za tridsať sekúnd namiesto hodiny kreslenia nesprávneho diagramu.

9 min čítaniaUML 2.5.13 z 35

What types exist,and how do they relate?Who uses it,and what for?What happens,in what order?What runswhere?Class diagramUse case diagramSequence diagramDeployment diagram
The four questions that account for most real diagrams, and the diagram each one wants.

01Start from the question, not the catalogue

Fourteen diagram types is a menu, and a menu is the wrong tool when you already know what you want to say. The reliable way in is to write down the question in one sentence and let the sentence pick the diagram. Almost every real question maps onto one of four.

ElementNotationWhat it means
What is it made of?ClassTypes, their attributes and how they relate. The class diagram is the default answer to any structural question and the one whose notation the rest borrow.
Who wants what from it?Use caseActors, goals and the system boundary. A use case diagram is a scope agreement, not a design.
What happens, in what order?SequenceParticipants and the messages between them, top to bottom. Reach for a sequence diagram when the order is the thing that is hard.
What runs where?DeploymentNodes, artifacts and the paths between them. The deployment diagram is what an infrastructure or security review actually needs.

The four questions that cover most work.

02The seven structure diagrams

A structure diagram shows what the system is made of, and nothing in it changes over time. All seven reuse class-diagram notation, so the cost of the sixth is far lower than the cost of the first.

ElementNotationWhat it means
ClassEverydayTypes, attributes, operations and relationships. The one to learn first and the one you will draw most.
ObjectOccasionalOne snapshot of real instances. An object diagram is how you show that a confusing class diagram does in fact hold together.
ComponentCommonDeployable units and the interfaces they provide and require. The component diagram is the closest UML gets to an architecture picture.
DeploymentCommonNodes, artifacts, and which artifact is deployed onto which node.
PackageOccasionalNamespaces and the dependencies between them. A package diagram is how a cycle between modules becomes visible.
Composite structureRareThe internals of one classifier: parts, ports and connectors. Useful in embedded and systems work, rarely elsewhere.
ProfileRareHow UML itself is extended - stereotypes and tagged values. You read a profile diagram far more often than you draw one.

03The seven behaviour diagrams

A behaviour diagram shows what happens, in what order and under what conditions. If your question has a when in it, you are here. Four of the seven are interaction diagrams, which differ mostly in what they put on which axis.

ElementNotationWhat it means
Use caseCommonActors, goals and scope. Deliberately says nothing about how.
ActivityEverydaySteps, branches, concurrency and responsibility. The activity diagramis UML's flowchart, with real semantics attached.
State machineCommonThe lifecycle of one object: states, events and transitions. A state machine earns its place the moment a status column exists.
SequenceEverydayMessages between participants, ordered down the page.
CommunicationOccasionalThe same interaction drawn as a network, with numbered messages. A communication diagram shows who talks to whom rather than when.
TimingRareState against a time axis. A timing diagram is for when the deadline itself is the requirement.
Interaction overviewRareAn activity diagram whose nodes are whole interactions - the index page for a set of sequence diagrams.

04The four that carry the load

Most teams draw four types and read a fifth. That is not a failure of ambition - it is what happens when every diagram has to be kept true. The other ten are worth being able to read when you meet one, which is a much smaller investment than being able to draw one cold.

Reach for it when

  • Class - the domain, once, kept current. The diagram most likely to still be true a year later.
  • Sequence - the one or two flows that are genuinely hard to explain in a paragraph.
  • Activity - a process crossing teams, where the swimlane is the whole point.
  • Deployment - any system whose infrastructure is not obvious from the repository.

Reach for something else when

  • Composite structure, unless you are doing embedded or systems engineering.
  • Timing, unless a deadline in milliseconds is part of the requirement.
  • Interaction overview, unless you already have several sequence diagrams to index.
  • Profile, unless you are extending UML itself rather than using it.

If you are learning rather than choosing, the order is the same: class first, because six of the structure diagrams reuse its notation; then sequence, because it is the one people ask for by name; then activity and use case, which are cheap once you can read a guard. The symbol reference covers the vocabulary all of them share.

05When the answer is not UML at all

Three questions look like UML questions and are not. Reaching for the wrong notation costs more than reaching for the wrong diagram, because the audience cannot read it either.

ElementNotationWhat it means
A database schemaERUse an ER diagram in crow's foot notation. Tables and keys are not classes and operations.
A business processBPMNUse BPMN when business analysts are the audience or the model is destined for an engine. An activity diagram is the right answer only when the audience is engineers.
An enterprise landscapeArchiMateUse ArchiMate when the subject spans business, application and technology. UML has no vocabulary for a business capability.

06What to remember

In one line each

  1. 01Write the question in one sentence first. The sentence picks the diagram; the catalogue never does.
  2. 02Structure diagrams answer what it is made of; behaviour diagrams answer what happens. A when in the question means behaviour.
  3. 03Four types carry most real work: class, sequence, activity and deployment.
  4. 04Activity is about work and responsibility; sequence is about messages and their order.
  5. 05If the subject is a schema, a business process or an enterprise landscape, the answer is ER, BPMN or ArchiMate rather than UML.

07Časté otázky

Ktorý UML diagram sa v praxi používa najčastejšie?

S veľkým odstupom diagram tried, za ním sekvenčný diagram. Spolu pokrývajú väčšinu návrhových diskusií: z čoho sa systém skladá a čo sa deje pri behu. Nasledujú diagramy prípadov použitia a aktivít, zvyčajne skôr pri zbere požiadaviek než pri návrhu.

Ktorý UML diagram zobrazuje priebeh procesu?

Diagram aktivít. Má akcie, rozhodnutia so strážami, rozvetvenia pre súbežnosť a plavecké dráhy pre zodpovednosť, čo je presne slovník, ktorý proces potrebuje. Sekvenčný diagram použite vtedy, keď je podstatné, ktorý účastník posiela ktorú správu.

Mám použiť diagram aktivít alebo sekvenčný diagram?

Opýtajte sa, o čom diagram je. Ak je o krokoch procesu a o tom, kto je za ktorý zodpovedný, použite diagram aktivít. Ak je o správach medzi konkrétnymi účastníkmi a ich poradí, použite sekvenčný. Aktivita je o práci, sekvencia o konverzácii.

Ktorý UML diagram zobrazuje štruktúru databázy?

Priamo žiadny. Najbližšie je diagram tried a často sa používa na doménový model, ale popisuje typy a správanie, nie tabuľky a kľúče. Na schému použite ER diagram v notácii vranej nohy, ktorá bola navrhnutá presne na to.

Koľko UML diagramov potrebuje jeden systém?

Zvyčajne tri až štyri, nie štrnásť. Diagram tried pre doménu, sekvenčný pre jeden či dva náročné toky a diagram nasadenia, ak infraštruktúra nie je zrejmá. Každý ďalší diagram je ďalší artefakt, ktorý musí niekto udržiavať pravdivý.

ZdieľaťXLinkedIn
Všetky články: UML
Všetky články