# Arrows: Is-a, Has-a and Uses

Boxes alone don't say how classes connect, so a class diagram joins them with four arrows (inherits, implements, has and uses), each with its own line and arrowhead, and each one read out loud as a sentence about the design.

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

By Gregor Dzierzon

## After this lesson you can

- Name the four arrows (inherits, implements, has, uses) by their line and arrowhead
- Read a class diagram out loud, and draw the arrow that a line of code means

## Key takeaways

- Inherits (is a) is a solid line with a hollow triangle pointing at the parent class.
- Implements (keeps the promise of) is a dashed line with a hollow triangle pointing at the interface.
- Has (has a) is a solid line with an open arrowhead pointing at what's kept in a field; uses is a dashed one, for something only handed in for a moment.
- Every arrow points from the class that knows to the class it knows about, and every arrow reads out loud as one sentence.

**Before this:** *Boxes: A Class on Paper*, and *Inheritance and Composition: Is-a and Has-a*.

Priya now has a box for every class at the rental desk: `Rentable`, `Bike`, `EBike`, `Scooter`, `CodeLock`, `Rental` and `Receipt`. Seven boxes on a page, and she still can't answer the questions that matter. Is an e-bike a kind of bike, or does it carry one around? Does a rental keep its bike, or only look at it? If she changes `Bike`, what else changes with it?

Those answers are the design, and they live in how the classes connect. A class diagram draws each connection as an arrow, and there are four arrows in this course. Learn them once, and you can read the diagram of every pattern that follows.

## The desk in code

Here is the desk, with one rental each for Maya, Sam and Dana. The receipt prints a line for a rental it's handed:

```csharp
Rental[] rentals =
{
    new Rental("Maya", new Bike("4821"), 2),
    new Rental("Sam", new EBike("7310"), 3),
    new Rental("Dana", new Scooter(), 1),
};
Receipt receipt = new Receipt();
foreach (Rental rental in rentals)
{
    receipt.Print(rental);
}

interface IRentable
{
    string Name { get; }
    int Price(int hours);
}

class CodeLock
{
    private string code;
    public CodeLock(string code) { this.code = code; }
    public bool Open(string tried) => tried == code;
}

class Bike : IRentable
{
    private CodeLock codeLock;
    public Bike(string lockCode) { codeLock = new CodeLock(lockCode); }
    public virtual string Name => "Bike";
    public virtual int Price(int hours) => 10 * hours;
}

class EBike : Bike
{
    public EBike(string lockCode) : base(lockCode) { }
    public override string Name => "E-bike";
    public override int Price(int hours) => 15 * hours;
}

class Scooter : IRentable
{
    public string Name => "Scooter";
    public int Price(int hours) => 8 * hours;
}

class Rental
{
    public string Rider { get; }
    public IRentable Item { get; }
    public int Hours { get; }

    public Rental(string rider, IRentable item, int hours)
    {
        Rider = rider;
        Item = item;
        Hours = hours;
    }

    public int Total() => Item.Price(Hours);
}

class Receipt
{
    public void Print(Rental rental)
    {
        Console.WriteLine($"{rental.Rider}: {rental.Item.Name}, {rental.Hours}h, ${rental.Total()}");
    }
}
```

```text
Maya: Bike, 2h, $20
Sam: E-bike, 3h, $45
Dana: Scooter, 1h, $8
```

```java
interface Rentable {
    String name();
    int price(int hours);
}

class CodeLock {
    private String code;
    CodeLock(String code) { this.code = code; }
    public boolean open(String tried) { return tried.equals(code); }
}

class Bike implements Rentable {
    private CodeLock lock;
    Bike(String lockCode) { lock = new CodeLock(lockCode); }
    public String name() { return "Bike"; }
    public int price(int hours) { return 10 * hours; }
}

class EBike extends Bike {
    EBike(String lockCode) { super(lockCode); }
    public String name() { return "E-bike"; }
    public int price(int hours) { return 15 * hours; }
}

class Scooter implements Rentable {
    public String name() { return "Scooter"; }
    public int price(int hours) { return 8 * hours; }
}

class Rental {
    String rider;
    Rentable item;
    int hours;

    Rental(String rider, Rentable item, int hours) {
        this.rider = rider;
        this.item = item;
        this.hours = hours;
    }

    public int total() { return item.price(hours); }
}

class Receipt {
    public void print(Rental rental) {
        IO.println(rental.rider + ": " + rental.item.name() + ", " + rental.hours + "h, $" + rental.total());
    }
}

void main() {
    List<Rental> rentals = List.of(
        new Rental("Maya", new Bike("4821"), 2),
        new Rental("Sam", new EBike("7310"), 3),
        new Rental("Dana", new Scooter(), 1));
    Receipt receipt = new Receipt();
    for (Rental rental : rentals) {
        receipt.print(rental);
    }
}
```

```text
Maya: Bike, 2h, $20
Sam: E-bike, 3h, $45
Dana: Scooter, 1h, $8
```

```python
from abc import ABC, abstractmethod


class Rentable(ABC):
    name = ""

    @abstractmethod
    def price(self, hours): ...


class CodeLock:
    def __init__(self, code): self._code = code
    def open(self, tried): return tried == self._code


class Bike(Rentable):
    name = "Bike"
    def __init__(self, lock_code): self._lock = CodeLock(lock_code)
    def price(self, hours): return 10 * hours


class EBike(Bike):
    name = "E-bike"
    def price(self, hours): return 15 * hours


class Scooter(Rentable):
    name = "Scooter"
    def price(self, hours): return 8 * hours


class Rental:
    def __init__(self, rider, item, hours):
        self.rider = rider
        self.item = item
        self.hours = hours

    def total(self):
        return self.item.price(self.hours)


class Receipt:
    def print(self, rental):
        print(f"{rental.rider}: {rental.item.name}, {rental.hours}h, ${rental.total()}")


rentals = [
    Rental("Maya", Bike("4821"), 2),
    Rental("Sam", EBike("7310"), 3),
    Rental("Dana", Scooter(), 1),
]
receipt = Receipt()
for rental in rentals:
    receipt.print(rental)
```

```text
Maya: Bike, 2h, $20
Sam: E-bike, 3h, $45
Dana: Scooter, 1h, $8
```

```javascript
class CodeLock {
  #code;
  constructor(code) { this.#code = code; }
  open(tried) { return tried === this.#code; }
}

class Bike {
  name = "Bike";
  #lock;
  constructor(lockCode) { this.#lock = new CodeLock(lockCode); }
  price(hours) { return 10 * hours; }
}

class EBike extends Bike {
  name = "E-bike";
  price(hours) { return 15 * hours; }
}

class Scooter {
  name = "Scooter";
  price(hours) { return 8 * hours; }
}

class Rental {
  constructor(rider, item, hours) {
    this.rider = rider;
    this.item = item;
    this.hours = hours;
  }

  total() { return this.item.price(this.hours); }
}

class Receipt {
  print(rental) {
    console.log(`${rental.rider}: ${rental.item.name}, ${rental.hours}h, $${rental.total()}`);
  }
}

const rentals = [
  new Rental("Maya", new Bike("4821"), 2),
  new Rental("Sam", new EBike("7310"), 3),
  new Rental("Dana", new Scooter(), 1),
];
const receipt = new Receipt();
for (const rental of rentals) {
  receipt.print(rental);
}
```

```text
Maya: Bike, 2h, $20
Sam: E-bike, 3h, $45
Dana: Scooter, 1h, $8
```

```typescript
interface Rentable {
  name: string;
  price(hours: number): number;
}

class CodeLock {
  private code: string;
  constructor(code: string) { this.code = code; }
  open(tried: string): boolean { return tried === this.code; }
}

class Bike implements Rentable {
  name = "Bike";
  private lock: CodeLock;
  constructor(lockCode: string) { this.lock = new CodeLock(lockCode); }
  price(hours: number): number { return 10 * hours; }
}

class EBike extends Bike {
  name = "E-bike";
  price(hours: number): number { return 15 * hours; }
}

class Scooter implements Rentable {
  name = "Scooter";
  price(hours: number): number { return 8 * hours; }
}

class Rental {
  rider: string;
  item: Rentable;
  hours: number;

  constructor(rider: string, item: Rentable, hours: number) {
    this.rider = rider;
    this.item = item;
    this.hours = hours;
  }

  total(): number { return this.item.price(this.hours); }
}

class Receipt {
  print(rental: Rental): void {
    console.log(`${rental.rider}: ${rental.item.name}, ${rental.hours}h, $${rental.total()}`);
  }
}

const rentals = [
  new Rental("Maya", new Bike("4821"), 2),
  new Rental("Sam", new EBike("7310"), 3),
  new Rental("Dana", new Scooter(), 1),
];
const receipt = new Receipt();
for (const rental of rentals) {
  receipt.print(rental);
}
```

```text
Maya: Bike, 2h, $20
Sam: E-bike, 3h, $45
Dana: Scooter, 1h, $8
```

The promise is written differently in each language: an `interface` in C# (named `IRentable`, since C# names interfaces with an `I` in front), Java and TypeScript; an abstract base class in Python; and nothing at all in JavaScript, where any object with a `name` and a `price` will do. The diagram draws all five the same way. (As in the last lesson, the TypeScript lock is `CodeLock`, since the browser's types already have a `CodeLock`.)

## Four arrows, four sentences

Every line of that code that connects two classes is one of four kinds:

| Arrow | The line | The head | Read it as | In the code |
|---|---|---|---|---|
| **Inherits** | solid | hollow triangle, at the parent | "is a" | `class EBike : Bike`, `extends Bike`, `class EBike(Bike)` |
| **Implements** | dashed | hollow triangle, at the interface | "keeps the promise of" | `class Bike : IRentable`, `implements Rentable` |
| **Has** | solid | open arrowhead (a plain V), at the part | "has a" | a field: `private CodeLock codeLock` |
| **Uses** | dashed | open arrowhead, at what's used | "uses" | a parameter or a local variable: `Print(Rental rental)` |

![The four arrows, each joining two boxes: inherits, solid with a hollow triangle (an e-bike is a bike); implements, dashed with a hollow triangle (a bike keeps the Rentable promise); has, solid with an open head (a bike has a lock); uses, dashed with an open head (a receipt uses a rental)](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/5afb5781beaf40c49de4c3e0b6957846.webp)

Two pairs make them easy to remember. **A triangle means "a kind of"**: the class is a kind of its parent, or a kind of thing that keeps the promise. **A dashed line means "lighter"**: implementing a promise is lighter than inheriting a whole class, and using something for a moment is lighter than keeping it.

The difference between *has* and *uses* is where the other object lives. A `Bike` keeps its lock in a field for its whole life: it *has* one. A `Receipt` is handed a rental, prints a line and forgets it: it only *uses* one. In the textbook UML words, *has* is an **association**, and *uses* is a **dependency**.

## Which way the arrow points

Every arrow points **from the class that knows to the class it knows about**. `Bike`'s code mentions `Rentable`; `Rentable`'s code never mentions `Bike`. So the arrow starts at `Bike`. That's worth knowing when you change things: change the class at the arrowhead, and every class at the other end of its arrows may need a look.

## The whole desk, read out loud

![The rental desk's class diagram: Bike and Scooter keep the Rentable promise, EBike inherits from Bike, Bike has a CodeLock, Rental has a Rentable, and Receipt uses a Rental, each connection drawn with its own line and arrowhead](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/96d9c35940274281982e3aae697c9071.webp)

Read each arrow as its sentence, and you have the design in six lines:

- An e-bike is a bike.
- A bike keeps the Rentable promise, and so does a scooter.
- A bike has a lock.
- A rental has a rentable.
- A receipt uses a rental.

Notice what there's no arrow for: `EBike` to `Rentable`. An e-bike already keeps the promise, because it's a bike; the diagram doesn't repeat it. And `Rental` points at `Rentable`, not at `Bike`: a rental can hold anything that keeps the promise, which is why Dana's scooter fit without a change. You can see that in one glance at the diagram, and it would take a careful read of the code.

**Try it.** Sam adds a `Helmet` class, and `Bike` gets a field that holds one. Which arrow do you draw, from where to where? (A solid line with an open arrowhead, from `Bike` to `Helmet`: a bike has a helmet.)

## Check yourself

2 questions to try on the lesson page.

## So what

Four arrows turn a page of boxes into a design you can read aloud, and check against the code. Next: how many of each, and who owns what.

## Key terms

- [Inheritance](https://www.ask-codey.com/glossary/inheritance-oop)
- [Interface](https://www.ask-codey.com/glossary/interface-oop)
- [Association](https://www.ask-codey.com/glossary/association-oop)
- [Dependency](https://www.ask-codey.com/glossary/dependency-oop)

## Cheat sheets

- [Arrows: Is-a, Has-a and Uses](https://www.ask-codey.com/cheat-sheets/dp-class-diagram-arrows-cheat-sheet)

Source: https://www.ask-codey.com/lessons/dp-class-diagram-arrows
