Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

Launch price

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year, or $19.50 for your first year with LAUNCH50, ends 1 Nov, 18:30 UTC.

See plansStart free instead

Module 08 · System Design · Low-level design: classes, properly

Has-a beats is-a (composition over inheritance)

Has-a Beats Is-a
Has-a Beats Is-a · Open board

The stack that let 99 in at the bottom, the front desk that holds a list instead, and the car that takes either engine.

Before you start. You need two ideas from earlier in this track. Nouns and verbs (from requirements to classes) turned a spoken requirement into classes and the job each one does. The object that keeps its own rules (encapsulation and invariants) showed an object guarding its own data, so no outside code can break its rules. This lesson asks how one class should reuse another class’s work without giving those rules away.

Lesson 37 of 73 in System Design

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year, or $19.50 for your first year with LAUNCH50, ends 1 Nov, 18:30 UTC.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • October 1994: a book with a sentence on page 20
  • The obvious way: inheritance, a family tree
  • The other way: composition, a parts list
  • What breaks later: the fragile base class
  • The same shape, many parts: polymorphism
  • So never inherit?

Terms it explains: inheritance, composition, delegation, fragile base class, polymorphism.

Review System Design