Skip to content
Tutorials Center
My learning

Topics

Lesson 4 of 39 ยท Getting Started

UML Notation Essentials

Learn the notation elements shared by every UML diagram: names, visibility marks, multiplicity, stereotypes, notes, constraints, tagged values, packages and profiles.

Before you learn any single diagram, it helps to know the small pieces of notation that appear in all of them. A stereotype looks the same on a class, a component and a node. A note attaches the same way to anything. Learn these once and every later diagram is easier to read.

Elements and relationships

Every UML diagram is built from two things: elements (boxes, ovals, lifelines, nodes) and relationships (lines and arrows between them). The shape of an element tells you its kind; the style of a line tells you the kind of relationship.

Line Meaning Where it appears
solid line association (a lasting link) class, object, component
solid line, hollow triangle generalization (inherits from) class, use case
dashed line, hollow triangle realization (implements) class, component
dashed line, open arrow dependency (uses) almost everywhere
solid line with filled or hollow diamond composition / aggregation class

You will study each one in context. For now, remember that line style and arrowhead carry the meaning. Do not choose arrows for looks.

Names

Naming conventions keep diagrams readable.

  • Classes, interfaces, use cases and components: PascalCase nouns (Order, PaymentGateway). Use case names are verb phrases (Place Order).
  • Attributes and operations: camelCase (totalPrice, calculateTax()).
  • Abstract names are shown in italics; static members are underlined (Mermaid uses $ and * suffixes).
  • Use the language of the domain. If the business says "Policy", do not draw InsuranceContractData.

Visibility

Members of a class can be marked with who may use them:

Mark Meaning
+ public
- private
# protected
~ package-private
classDiagram
    class Wallet {
        -float balance
        #String currency
        ~int internalId
        +deposit(float amount)
        +getBalance() float
    }

Private data, public behavior: the usual shape of an encapsulated class.

Multiplicity

Multiplicity says how many instances take part in a relationship end.

Notation Meaning
1 exactly one
0..1 zero or one (optional)
* or 0..* zero or more
1..* one or more
2..5 between two and five

Put it near the end of the line it describes. Associations and Multiplicity goes into detail.

Stereotypes

A stereotype labels an element with an extra category, written in guillemets: <<interface>>, <<enumeration>>, <<service>>. It extends the vocabulary without inventing new shapes.

classDiagram
    class Payable {
        <<interface>>
        +pay(float amount)
    }
    class Color {
        <<enumeration>>
        RED
        GREEN
        BLUE
    }
    class OrderService {
        <<service>>
        +placeOrder()
    }

Some stereotypes are standard (<<interface>>, <<enumeration>>, <<abstract>>, <<create>>); others are yours (<<entity>>, <<repository>>). When you invent one, define it once in a legend.

Notes and constraints

A note is a dog-eared rectangle connected to an element by a dashed line. It holds comments that do not fit the notation. A constraint is a rule in curly braces, such as {balance >= 0}, written near the element it restricts. Constraints can be informal text or formal OCL (the Object Constraint Language).

classDiagram
    class Account {
        -float balance
        +withdraw(float amount)
    }
    note for Account "Invariant: balance >= 0<br/>Withdraw fails if amount > balance"

Useful constraint examples: on a multi-valued end, , on an attribute, between two associations.

Tagged values and profiles

A tagged value adds a named property to an element: {author = "Sam", version = 2}. A profile is a packaged set of stereotypes and tagged values that tailors UML to a domain: a profile for SysML, for a specific framework, for your company. This is how UML stays one language yet serves many industries.

Packages and namespaces

A package is a folder for model elements, drawn as a tab-shaped rectangle. Packages stop big models from turning into a hairball and give names a namespace: shop::Order versus billing::Order.

flowchart LR
    subgraph shop
        Order
        Cart
    end
    subgraph billing
        Invoice
        Payment
    end
    Order -.-> Invoice

Mermaid has no package diagram; a flowchart subgraph stands in. The dashed arrow is a dependency: shop depends on billing.

Python Parse and print UML member notation

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Python Check a multiplicity against a real count

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Reading a complete example

Parts of one class box

Stereotype <<entity>> above the name.
Name PascalCase noun.
Attributes Visibility, name, type.
Operations Name(params) returnType.

Notes and constraints attach to any of these.

1 / 2

Do not use notation you cannot explain. If readers must guess what an arrowhead means, either add a legend or use a simpler diagram.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does the - mark before a member mean?

    • is public, - is private, # is protected, ~ is package-private.
  2. 2. What does multiplicity 0..1 on an association end express?

    0..1 means the relationship may be absent or hold a single instance.
  3. 3. What is a stereotype?

    Stereotypes such as <<interface>> extend UML's vocabulary without new shapes.
  4. 4. What is the purpose of a UML profile?

    Profiles customize UML for domains like SysML or a company's own conventions.

Summary

  • Diagrams combine elements and relationships; line style and arrowhead carry meaning.
  • Use PascalCase for types, camelCase for members, domain words for names.
  • Visibility: + public, - private, # protected, ~ package.
  • Multiplicity states how many instances take part: 1, 0..1, *, 1..*.
  • Stereotypes, notes, constraints and tagged values extend the notation; profiles bundle them.
  • Packages group elements and provide namespaces.

Next: Classes and Members