# In Your Textbook: UML

A college class or a textbook's pattern diagram uses UML's formal words and marks (realization, stereotypes, italics for abstract, # and ~, notes), and the original pattern book used an older style; this optional lesson maps them to this chapter, and says in a paragraph each what the other UML diagrams show.

Journeyman · Software Development · OOP · Updated November 17, 2026

By Gregor Dzierzon

## After this lesson you can

- Read a textbook's UML: stereotypes, italics for abstract, notes, and the # and ~ marks
- Name the UML diagrams this course doesn't teach (communication, activity, use case, component, package) by what each shows

## Key takeaways

- The textbook names this chapter's arrows generalization (inherits), realization (implements), association (has) and dependency (uses).
- A stereotype is a word in guillemets, such as «interface», that says what kind of thing a box or arrow is.
- Italics mean abstract, an underline means static (it belongs to the class), # means protected and ~ means package.
- A note is a box with a folded corner, joined by a dashed line; the original pattern book often put a little pseudocode in one.
- Communication, activity, use case, component and package diagrams show other things: calls on links, workflows, users' goals, a system's parts, and folders of classes.

**Before this:** the rest of this chapter, from *Boxes: A Class on Paper* to *Draw Your Own*. This lesson is optional: nothing later in the course depends on it.

Maybe your software design class assigned a chapter on design patterns, and the textbook's Strategy diagram has a box marked «interface», a class name in italics, a folded-corner note with code in it, and a `#` in front of a field. Or an exam asks you to "draw the realization between `Bike` and `Rentable`". You know what those mean already; you've learned them under plainer names. This lesson matches the formal words to the ones in this chapter, and covers the few marks the chapter didn't need.

## The textbook's words for this chapter's arrows

| This course says | The textbook says | Drawn as |
|---|---|---|
| inherits (is a) | **generalization** | solid line, hollow triangle |
| implements (keeps the promise of) | **realization** | dashed line, hollow triangle |
| has (has a) | **association**, often with a role name at the end, such as `-lock` | solid line, open arrowhead |
| uses | **dependency** | dashed line, open arrowhead |
| the hollow and filled diamonds | **aggregation** and **composition** | the same |
| the numbers on a line | **multiplicity** | the same |

A textbook may also leave the arrowhead off an association: a plain line means the two classes know about each other, and an arrowhead means only one end knows (UML calls that *navigability*).

## A textbook's class, in code

Here's a design the textbook would draw with every mark in this lesson: an abstract `Vehicle` that keeps the rate (protected, so only it and its subclasses can see it) and counts how many vehicles were made (static, so the count belongs to the class, not to each object):

```csharp
Vehicle[] fleet = { new Bike(), new Scooter() };
foreach (Vehicle vehicle in fleet)
{
    Console.WriteLine($"{vehicle.Name}: ${vehicle.Price(1)}");
}
Console.WriteLine($"Vehicles made: {Vehicle.Count}");

abstract class Vehicle
{
    public static int Count = 0;
    protected int rate;

    protected Vehicle(int rate)
    {
        this.rate = rate;
        Count++;
    }

    public abstract string Name { get; }
    public int Price(int hours) => rate * hours;
}

class Bike : Vehicle
{
    public Bike() : base(10) { }
    public override string Name => "Bike";
}

class Scooter : Vehicle
{
    public Scooter() : base(8) { }
    public override string Name => "Scooter";
}
```

```text
Bike: $10
Scooter: $8
Vehicles made: 2
```

```java
abstract class Vehicle {
    static int count = 0;
    protected int rate;

    protected Vehicle(int rate) {
        this.rate = rate;
        count++;
    }

    public abstract String name();
    public int price(int hours) { return rate * hours; }
}

class Bike extends Vehicle {
    Bike() { super(10); }
    public String name() { return "Bike"; }
}

class Scooter extends Vehicle {
    Scooter() { super(8); }
    public String name() { return "Scooter"; }
}

void main() {
    List<Vehicle> fleet = List.of(new Bike(), new Scooter());
    for (Vehicle vehicle : fleet) {
        IO.println(vehicle.name() + ": $" + vehicle.price(1));
    }
    IO.println("Vehicles made: " + Vehicle.count);
}
```

```text
Bike: $10
Scooter: $8
Vehicles made: 2
```

```python
from abc import ABC, abstractmethod


class Vehicle(ABC):
    count = 0

    def __init__(self, rate):
        self._rate = rate
        Vehicle.count += 1

    @property
    @abstractmethod
    def name(self): ...

    def price(self, hours):
        return self._rate * hours


class Bike(Vehicle):
    def __init__(self): super().__init__(10)

    @property
    def name(self): return "Bike"


class Scooter(Vehicle):
    def __init__(self): super().__init__(8)

    @property
    def name(self): return "Scooter"


fleet = [Bike(), Scooter()]
for vehicle in fleet:
    print(f"{vehicle.name}: ${vehicle.price(1)}")
print(f"Vehicles made: {Vehicle.count}")
```

```text
Bike: $10
Scooter: $8
Vehicles made: 2
```

```javascript
class Vehicle {
  static count = 0;

  constructor(rate) {
    this.rate = rate;
    Vehicle.count++;
  }

  get name() { throw new Error("Each kind of vehicle gives its own name."); }
  price(hours) { return this.rate * hours; }
}

class Bike extends Vehicle {
  constructor() { super(10); }
  get name() { return "Bike"; }
}

class Scooter extends Vehicle {
  constructor() { super(8); }
  get name() { return "Scooter"; }
}

const fleet = [new Bike(), new Scooter()];
for (const vehicle of fleet) {
  console.log(`${vehicle.name}: $${vehicle.price(1)}`);
}
console.log(`Vehicles made: ${Vehicle.count}`);
```

```text
Bike: $10
Scooter: $8
Vehicles made: 2
```

```typescript
abstract class Vehicle {
  static count = 0;
  protected rate: number;

  protected constructor(rate: number) {
    this.rate = rate;
    Vehicle.count++;
  }

  abstract get name(): string;
  price(hours: number): number { return this.rate * hours; }
}

class Bike extends Vehicle {
  constructor() { super(10); }
  get name(): string { return "Bike"; }
}

class Scooter extends Vehicle {
  constructor() { super(8); }
  get name(): string { return "Scooter"; }
}

const fleet: Vehicle[] = [new Bike(), new Scooter()];
for (const vehicle of fleet) {
  console.log(`${vehicle.name}: $${vehicle.price(1)}`);
}
console.log(`Vehicles made: ${Vehicle.count}`);
```

```text
Bike: $10
Scooter: $8
Vehicles made: 2
```

C#, Java and TypeScript have `abstract` and `protected` keywords. Python has neither: an abstract base class stands in for `abstract`, and a leading underscore, `_rate`, is the convention for "only this class and its subclasses". JavaScript has no `abstract` or `protected` at all; its `Vehicle` throws an error if a subclass forgets its name.

## Stereotypes, italics, underlines, and two more marks

Here's that design as a textbook would draw it:

![A textbook-style UML diagram: the abstract class Vehicle, its name in italics with {abstract}, a protected # rate, an underlined static count and an italic name(), with Bike and Scooter inheriting from it, a folded-corner note on price, and a separate «interface» Rentable](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/8297206f88f645738731eb6adfd9887b.webp)

- **Stereotypes** are words in guillemets, the « » marks, that say what kind of thing a box or an arrow is. You've seen «interface». Others you'll meet: «enumeration» for a fixed list of values, «abstract» on some diagrams, and «create» or «use» written on a dependency arrow to say how one class depends on another.
- **Italics mean abstract**, for a class or a method. Since italics are hard to see, a textbook may add `{abstract}` too. A word in curly braces is a *constraint* or *property*: `{readOnly}`, `{ordered}`.
- **An underline means static**: `count` belongs to the class itself, shared by every object, not kept by each one.
- **Two more visibility marks** join `+` and `-`: `#` is **protected** (the class and its subclasses) and `~` is **package** (any code in the same package or namespace).
- **A note** is a box with a folded corner, joined by a dashed line to whatever it explains. It can hold a sentence or a little code.

## The original pattern book's style

The 1994 book that named 23 patterns, by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides (often called the "Gang of Four"), was written shortly before UML became the standard in 1997. Its diagrams use an older notation, OMT, which UML grew out of, so most of it will look familiar: boxes in three parts, a triangle for inheritance, abstract names in italics. Two things differ: a **filled dot** at an arrowhead means "many", and an arrow with a **diamond at its start** means aggregation. The book also puts pseudocode in notes, and names its boxes by role (`Context`, `Strategy`, `ConcreteStrategyA`), which is where this course's role diagrams take their small gray names from.

## The diagrams this course doesn't teach

UML has more diagrams than a patterns course needs. Sequence diagrams (who calls whom, in order) come in Pass 2, and state diagrams with the State pattern. The rest, a paragraph each:

![Five small diagrams this course doesn't teach, each named: a communication diagram of numbered calls, an activity diagram of renting a bike, a use case diagram of a rider and a clerk, a component diagram of an app and a payment service, and a package diagram of two folders](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/d338adeb17f5446483bddb10869944b0.webp)

- **Communication diagram.** It shows what a sequence diagram shows, which object calls which, but drawn as objects joined by lines with numbered messages on them, instead of along a timeline. Handy when the links matter more than the timing.
- **Activity diagram.** A flowchart of a workflow: rounded boxes for steps, diamonds for choices, a thick bar where work splits or joins. It's for a process (renting a bike, start to finish), not for classes.
- **Use case diagram.** Who uses the system, and for what: stick figures (*actors*, such as a rider or a clerk) joined to ovals (*use cases*, such as "rent a bike"). It belongs to gathering requirements, before design.
- **Component diagram.** The big parts of a system, such as a rental app and a payment service, and the interfaces between them. It belongs to architecture, a level above classes.
- **Package diagram.** Folders of classes (packages or namespaces) and which folder depends on which. It's useful when a codebase is large enough to need folders.

## Check yourself

2 questions to try on the lesson page.

## So what

The textbook's words are this chapter's ideas with formal names: realization is "keeps the promise", a stereotype is a label in « », and an underline is static. With them, a college UML question is one you can already answer.

## Key terms

- [Unified Modeling Language (UML)](https://www.ask-codey.com/glossary/unified-modeling-language-uml)
- [UML Stereotype](https://www.ask-codey.com/glossary/uml-stereotype)
- [Activity Diagram](https://www.ask-codey.com/glossary/activity-diagram)
- [Use Case Diagram](https://www.ask-codey.com/glossary/use-case-diagram)

## Cheat sheets

- [In Your Textbook: UML](https://www.ask-codey.com/cheat-sheets/dp-uml-in-your-textbook-cheat-sheet)

Source: https://www.ask-codey.com/lessons/dp-uml-in-your-textbook
