UML Toolkit (Cheatsheet)

Context: FIT2099_MOC · the one-note UML surface for the assignment — draw a class diagram, a sequence diagram, or a domain/process model from a blank page. Depth in the linked notes.

Quick Revision

  • 🎯 Objective: capture a design two ways ➔ class diagram = static structure (classes + relationships), sequence diagram = dynamic behaviour (messages over time).
  • ⚡ Key Constraint: get the relationship arrow right on the class diagram (generalisation vs realization vs association vs dependency) and remember diagrams are an aid to shared understanding, not the deliverable — see Software Design in the Lifecycle (FIT2099).

📐 Class diagram — box anatomy

classDiagram
    class BankAccount {
        <<abstract>>
        -double balance
        #int id
        +deposit(double amt) void
        +getBalance() double$
    }
  • Three compartmentsName (top, italic/<<abstract>> if abstract) · Attributes (middle) · Operations (bottom).
  • Member linevisibility name : Type for fields, visibility name(params) : ReturnType for methods.
  • Static ➔ underlined (Mermaid: trailing $). Abstract ➔ italic / <<abstract>>.

👁️ Visibility & stereotypes

SymbolMeaningMermaid
+public+m()
-private-x
#protected#x
~package/default~x
«abstract» / italicsabstract class or method<<abstract>>
«interface»interface<<interface>>
«enumeration»enum<<enumeration>>

(Full legend: UML Class Diagrams (Java).)

🔗 Relationship arrows (the assessable core)

RelationshipMeaning (Java)UML arrowMermaid
Generalisationinheritance, extends (is-a)solid line, hollow triangle`Base <
Realizationimplements an interfacedashed line, hollow triangle`Iface <
Associationhas-a, stored as a fieldsolid line, open arrowA --> B
Dependencyuses-a, method param/local («use»)dashed line, open arrowA ..> B
Aggregationshared whole-part (hollow ◇)hollow diamondWhole o-- Part
Compositionowned whole-part (filled ◆)filled diamondWhole *-- Part

Association vs Dependency (top exam trap): if the other class is a stored fieldassociation (solid -->). If it only appears as a method parameter / localdependency (dashed ..>). See UML Associations and Dependencies (Java).

  • Multiplicity ➔ label the ends: 1, 0..1, * (many), 1..* (one or more). E.g. Customer "1" --> "*" Order.

Worked class diagram (all four assessable arrows)

classDiagram
    class Speaker { <<interface>> +speak() String }
    class Animal { <<abstract>> #String name +speak() String }
    class Dog { +speak() String +fetch() void }
    class Owner { -Dog pet +walk() void }
    class VetVisit { +treat(Animal a) void }
    Speaker <|.. Animal : realization
    Animal <|-- Dog : generalisation
    Owner --> Dog : association (field)
    VetVisit ..> Animal : «use» dependency (param)

⏱️ Sequence diagram — dynamic anatomy

sequenceDiagram
    participant P as Player
    participant A as AttackAction
    participant E as Enemy
    P->>A: execute(enemy)
    activate A
    A->>E: getHitPoints()
    E-->>A: hp
    alt hp > 0
        A->>E: hurt(damage)
    else already dead
        A-->>P: "no target"
    end
    deactivate A
ElementMeaningMermaid
Lifelinean object over time (concrete classes only)participant E as Enemy
Synchronous messagecaller waitsA->>E: m()
Return messagevalue backE-->>A: hp
Activation barobject is executingactivate/deactivate
Create / deleteobject born/destroyed mid-scenariomessage to create, destroy
altbranch (if/else)alt cond ... else ... end
optoptional (if, no else)opt cond ... end
looprepetitionloop while cond ... end

(Every alt/opt/loop needs a matching end. Depth: UML Sequence Diagrams (Java).)

🗺️ Modelling & process diagrams (design-process toolkit)

ToolUseNote
Conceptual/Domain class diagramunderstand domain concepts + relationships before designingDesign Process and Techniques (FIT2099)
Activity diagrammodel a business process / control flow(Week 11)
Use caseactor-action / system-response scenario scriptambiguity + tedium are its downsides
CRC cardClass · Responsibilities · Collaborators (collaborators → associations)CRC Cards (FIT2099)
Package diagramgroup classes into namespacesJava Packages and Imports

✍️ Integration Practice (≥3 diagram tools — draw from blank)

⚠️ Common Mistakes

  • 💡 Association vs dependency ➔ field = solid -->; parameter-only = dashed ..>. Mixing them is the most common class-diagram deduction.
  • 💡 Generalisation vs realizationextends = solid hollow triangle (<|--); implements = dashed hollow triangle (<|..).
  • 💡 Unbalanced fragments ➔ each alt/opt/loop must close with end, or the sequence diagram won’t render.
  • 💡 Abstract objects on a sequence diagram ➔ lifelines are concrete runtime objects; don’t put an interface/abstract type on a lifeline.
  • 💡 Diagram as the goal ➔ diagrams serve shared understanding; keep them only as detailed as the reader needs.