Skip to content

The delivery framework: approaching a design problem

Difficulty: Beginner

Key concepts

  • delivery framework
  • requirements
  • out of scope
  • entities
  • relationships
  • class design
  • data members
  • member functions
  • verification trace
  • extensibility
  • design workflow
  • Five steps that take you from a one-line problem to a design you can explain: requirements, entities and relationships, class design, implementation, and extensibility.
  • What each step produces, so that you always know whether a step is finished.
  • How long to spend on each step when time is short, as in a design interview.
  • How the five steps expand into the site’s full 12-step workflow for real projects.
  • All five steps, worked through on tic-tac-toe in C++.

Most design attempts that fail do so in one of two ways:

  • Coding too early. You hear “tic-tac-toe”, start writing a Board class, and discover twenty minutes later that you never asked whether the board size can change, or what happens when someone plays out of turn. An unasked question often comes back as a rewrite.
  • Never getting to the design. You spend so long listing requirements and drawing boxes that there is no time left to show how the classes actually work.

The delivery framework avoids both. It is a fixed order of five steps, each with a small written output. You move on when the output exists, and you come back to a step when a later one shows it was incomplete.

Step Question it answers Output Time in a 45-minute session
1. Requirements What exactly must it do, and what is out of scope? A numbered list of requirements, and an “out of scope” list about 5 minutes
2. Entities and relationships Which things are there, and how do they connect? A short list of classes, and a sketch of who owns or uses whom about 3–5 minutes
3. Class design What does each class remember, and what can it do? For each class: its data members and member functions, with reasons about 10–15 minutes
4. Implementation Does the design actually work? Code for the important member functions, and a trace of one scenario about 10–15 minutes
5. Extensibility What happens when the requirements change? Short explanations of how the design absorbs likely changes about 5 minutes

The times are a guide for a timed session, not a rule. On a real project the same steps take hours or days, and each one expands into several steps of the full workflow (described at the end of this page).

The five steps in order, each with its output; dashed arrows show the usual reasons to go back
Text description of the diagram

Five boxes in a row, joined by solid arrows: 1 Requirements (output: a numbered list and an out-of-scope list), 2 Entities and relationships (output: the classes and a sketch of how they connect), 3 Class design (output: each class’s data members and member functions), 4 Implementation (output: the key functions and a trace of one scenario), and 5 Extensibility (output: how likely changes fit). Two dashed arrows go back: from class design to requirements, when designing a class reveals a rule nobody stated; and from implementation to class design, when writing the code reveals a responsibility no class has.

Diagram source (Mermaid)
flowchart LR
R["1 Requirements<br/>numbered list + out of scope"] --> E["2 Entities and relationships<br/>classes + sketch"]
E --> C["3 Class design<br/>data members + member functions"]
C --> I["4 Implementation<br/>key functions + trace"]
I --> X["5 Extensibility<br/>how changes fit"]
C -.->|a rule nobody stated| R
I -.->|a missing responsibility| C

The rest of the page runs the five steps on one problem:

“Design a tic-tac-toe game.”

Goal: turn a short, vague prompt into a list of requirements that are clear enough to design from, and an explicit list of what you will not build.

How: ask questions in four groups. Each group catches a different kind of gap.

Group Example questions for tic-tac-toe Answer (from whoever set the problem)
Core actions Who plays? Two people at one device, or against the computer? Two people, taking turns
Rules and end of the game What board size? Who starts? How does the game end? 3 × 3; X starts; a line of three wins, a full board with no line is a draw
Errors What if someone plays out of turn, on a taken cell, or after the game ends? Refuse the move, say why, change nothing
Scope A user interface? Saving games? Several games at once? Undo? No; one game in memory; no undo

Write the answers down as numbered requirements, so that later steps can refer to them:

Requirements
1. Two players, X and O, take turns placing their mark on a 3 x 3 board.
X moves first.
2. A move names the player and a cell (row, column).
3. A move is refused, with a reason, if the game is over, it is not that
player's turn, the cell is outside the board, or the cell is taken.
A refused move changes nothing.
4. A player who completes a row, column, or diagonal wins. A full board
with no line is a draw.
5. Anyone can see the board, whose turn it is, and the game's state.
Out of scope
- A user interface (text, graphics, or network)
- A computer opponent
- Undo, saving, and move history
- Board sizes other than 3 x 3

The out-of-scope list matters as much as the requirements. It tells you what you may leave out, and it records what you deliberately left out, so that nobody mistakes it for an oversight.

The requirements lessons (REQ-01 to REQ-11) teach this step in depth: how to find questions, separate assumptions from answers, and write requirements that can be tested.

Goal: decide which classes exist and how they connect, before deciding what is inside them.

How: underline the nouns in the requirements (players, X, O, mark, board, cell, row, column, move, game, line, win, draw, state, reason). Then decide what each one becomes:

  • A noun that holds changing state or enforces a rule becomes a class.
  • A noun that is only a piece of information about something else becomes a data member, an enum, or a parameter.
  • A noun outside the system (a person, another program) becomes an interface (an abstract class that says what the outside thing can do, so the design can talk to it without knowing how it works), or nothing at all.
Noun Becomes Why
game class Game Holds whose turn it is and whether the game has ended; enforces the turn and end rules
board class Board Holds the nine cells; answers “is this cell free?” and “is there a line?”
X, O, mark enum class Mark Just a value: which of two symbols
player nothing (a Mark is enough) A player has no data and no behaviour here beyond their mark
cell, row, column int row, int col parameters Positions on the board, not things with behaviour
move parameters of Game::play Nothing remembers a move after it is played (move history is out of scope)
state, draw, win enum class GameState One of four situations
line a member function of Board A question about the board, not a thing
reason (for a refusal) enum class MoveResult One of five outcomes of a move (requirement 3: refused, with a reason)

Notice how few classes there are. Turning every noun into a class would give you Player, Cell, Move, and Line classes with nothing to do. MOD-11 teaches this filtering step in detail.

Next, the relationships. Ask: which class runs the main workflow? (Game: it receives each move.) Which class owns which data? (Game owns the Board; the Board owns the cells.)

Entity sketch: Game owns one Board; the Board stores Mark values in its cells
Text description of the diagram

Three boxes: Game, Board, and Mark. A solid arrow labelled “owns 1” goes from Game to Board: each game has exactly one board, created and destroyed with it. A solid arrow goes from Board to Mark, labelled “stores 9 cells, each empty or a”: the board keeps the marks inside itself. A dashed arrow labelled “uses” goes from Game to Mark: the game passes marks around but does not store the board’s cells. On this site, a solid arrow means “holds inside itself and destroys with itself” (ownership), and a dashed arrow means “uses, without owning”. The sketch shows only the main types; the two result enums appear in step 3.

Diagram source (Mermaid)
flowchart LR
Game -->|owns 1| Board
Board -->|stores 9 cells, each empty or a| Mark
Game -.->|uses| Mark

Goal: for each class, decide what it must remember (its data members) and what others can ask it to do (its member functions). Every member should be there because a requirement needs it.

How: start with the class that runs the workflow, then go down to the classes it uses. For each class, fill in two tables.

What must Game remember? Go through the requirements it is responsible for:

Requirement What Game must remember Data member
1. players take turns, X first whose turn it is Mark current_ (starts as X)
3, 4. refuse moves after the end; win, draw whether the game is running, won, or drawn GameState state_
1, 4, 5. the board and its marks the board Board board_, a member object (not a pointer)

What must others be able to ask Game to do?

Need Who needs it Member function
make a move and learn whether it was refused (2, 3) the caller MoveResult play(Mark player, int row, int col)
see whose turn it is (5) the caller Mark current_player() const
see whether the game has ended, and how (5) the caller GameState state() const
see the board (5) the caller const Board& board() const

“The caller” is whatever drives the game: main.cpp in the example, a user interface later. There are only four functions. Nothing outside Game can change the turn or the state directly; the only way in is play, which is where the rules are checked. play returns a MoveResult rather than bool because requirement 3 asks for a reason when a move is refused.

current_player() answers “whose turn is it?” only while state() is in_progress. After a win the turn does not advance, so it still names the winner; a caller should check the state first.

This is the one real choice in Game, so compare the options.

With more players, or when a state needs more data (for example, the cells of the winning line), the state can carry that data: a std::variant of small structs, one per state. That is more than tic-tac-toe needs, so the example uses the enum. State machines are covered in MOD-10.

Requirement What Board must remember Data member
1. a 3 × 3 board of marks the mark in each cell, or that it is empty std::array<std::optional<Mark>, size * size> cells_ (with static constexpr int size = 3)
Need Who needs it Member function
is a position on the board? (3) Game static bool in_bounds(int row, int col)
is a cell free? (3) Game bool is_empty(int row, int col) const
put a mark in a cell (1) Game void place(int row, int col, Mark mark)
has this mark made a line? (4) Game bool has_line(Mark mark) const
is every cell taken? (4) Game bool is_full() const
what is in a cell? (5) the caller std::optional<Mark> mark_at(int row, int col) const

class Game

runs one game: turns, end, winner

Data members

  • Board board_; a member object: created and destroyed with the game
  • Mark current_; X first
  • GameState state_; in_progress at the start

Member functions

  • MoveResult play(Mark player, int row, int col);
  • GameState state() const;
  • Mark current_player() const;
  • const Board& board() const;

class Board

the 3 x 3 grid: cells and lines, no rules about turns

Data members

  • static constexpr int size = 3;
  • std::array<std::optional<Mark>, size * size> cells_; empty cell = std::nullopt

Member functions

  • static bool in_bounds(int row, int col);
  • bool is_empty(int row, int col) const;
  • void place(int row, int col, Mark mark); throws unless the cell is inside and empty
  • bool has_line(Mark mark) const;
  • bool is_full() const;
  • std::optional<Mark> mark_at(int row, int col) const;

enum class Mark

Values

  • x
  • o

enum class GameState

Values

  • in_progress
  • x_won
  • o_won
  • draw

enum class MoveResult

Values

  • accepted
  • game_over
  • not_your_turn
  • out_of_bounds
  • cell_taken
Class outline for tic-tac-toe: Game runs the game and owns the Board; Board knows cells and lines

A class outline lists each data member (marked - in the source) and each member function (marked +) as a C++ declaration, with a short note where it helps. It leaves out small helpers: the example also has a free function other(Mark) that returns the opposite mark. MOD-08 explains the notation; it is used on every page of this site.

A rule belongs to the class that owns the data the rule is about:

  • “A cell can hold only one mark” and “a line is three in a row” are about cells, so they live in Board.
  • “Players alternate”, “no moves after the end”, and “a line wins” are about the game as a whole, so they live in Game.

That split is why Board has no idea whose turn it is, and Game never looks at individual cells except through Board’s functions. If the win rule changed (say, to four in a row), only Board::has_line would change; Game’s rules would stay the same.

Goal: show that the design works, by writing the functions that carry the important logic. In an interview, ask how much code is expected; on a project, write it all, with tests.

How: for each important function, first say the happy path in a sentence, then list the edge cases, then write it.

For Game::play: “Check the move. If it is allowed, place the mark, then decide whether the game is won, drawn, or continues with the other player.” The edge cases are the four refusals from requirement 3, and one subtle case: a move that fills the last cell and completes a line is a win, not a draw. Checking for a line before checking for a full board handles it.

VerifiedCompiled and tested with GNU 11.4.0 and Clang 14.0.0 (C++20, 2026-12-01).

game.cpp
MoveResult Game::play(Mark player, int row, int col) {
// Check everything first, so that a refused move changes nothing.
if (state_ != GameState::in_progress) return MoveResult::game_over;
if (player != current_) return MoveResult::not_your_turn;
if (!Board::in_bounds(row, col)) return MoveResult::out_of_bounds;
if (!board_.is_empty(row, col)) return MoveResult::cell_taken;
// The move is legal: play it, then decide what happens next. Only the
// player who just moved can have made a line, so only they are checked.
board_.place(row, col, player);
if (board_.has_line(player)) {
state_ = player == Mark::x ? GameState::x_won : GameState::o_won;
} else if (board_.is_full()) {
state_ = GameState::draw; // no line and no empty cell: nobody can win
} else {
current_ = other(player); // the game goes on: hand the turn over
}
return MoveResult::accepted;
}
How this code works: Game::play

play has two halves: check, then change.

  1. The four checks. Each if asks one question and, if the answer is bad, leaves at once with return, handing back the reason as a MoveResult. Because each check returns immediately, the code below it only runs when every earlier check passed. The order matters. “The game is over” is reported before “not your turn”, because once the game is over, nobody’s turn is right. And in_bounds must come before is_empty: is_empty reads the cell, and asking for a cell off the board throws std::out_of_range, so the bounds check keeps that call safe.
  2. The change. board_.place(row, col, player) puts the mark down. The checks above have already made sure this cannot throw.
  3. What happens next. Exactly one of three things:
    • the player who just moved has a line, so they win (x_won or o_won);
    • otherwise, if the board is full, it is a draw;
    • otherwise the turn passes to the other player, with other(player).
  4. return MoveResult::accepted tells the caller the move was played.

Two things are worth noticing. The win check comes before the full check, so a move that fills the last cell and completes a line counts as a win. And when the game ends, current_ is left alone: there is no next player, and the next call to play is refused at the first check.

Every check comes before the first change. That is how requirement 3’s “a refused move changes nothing” is guaranteed: there is no path where the board changes and then the move is refused.

There are two kinds of failure here, handled differently. A refused move is an expected outcome (players make mistakes), so play returns it as a MoveResult. Calling Board::place on a taken or outside cell is a programming error (the caller should have checked), so Board throws an exception (std::logic_error). That is why Game checks in_bounds and then is_empty before calling place: the checks keep the exception from ever happening in a correct program. The C++ foundations section covers this choice in the lesson on errors and contracts.

Board::has_line checks each row, each column, and both diagonals:

VerifiedCompiled and tested with GNU 11.4.0 and Clang 14.0.0 (C++20, 2026-12-01).

board.cpp
// Does `mark` fill a whole row, a whole column, or one of the two
// diagonals? One pass over i = 0, 1, 2 checks row i, column i, and the
// diagonal cells on step i, so no line is visited twice.
bool Board::has_line(Mark mark) const {
// A small helper, so the loops read like English: is(r, c) means "does
// the cell at row r, column c hold this mark?". It is a lambda: [&]
// lets it use `mark` and this board without copying them. An empty
// cell is std::nullopt, which never equals a Mark, so it counts as no.
const auto is = [&](int row, int col) { return mark_at(row, col) == mark; };
// Start by assuming each diagonal is complete, and let a single cell
// that does not match prove otherwise. Once a flag is false, `&&`
// keeps it false: false && anything is false.
bool diagonal = true; // top-left to bottom-right: (0,0) (1,1) (2,2)
bool anti_diagonal = true; // top-right to bottom-left: (0,2) (1,1) (2,0)
for (int i = 0; i < size; ++i) {
// The same "assume yes, look for a no" idea, for row i and column i.
bool row_full = true;
bool col_full = true;
for (int j = 0; j < size; ++j) {
row_full = row_full && is(i, j); // along row i: (i,0) (i,1) (i,2)
col_full = col_full && is(j, i); // down column i: (0,i) (1,i) (2,i)
}
if (row_full || col_full) return true; // a line is found: stop early
// On step i, the main diagonal's cell is (i, i), and the other
// diagonal's is (i, size - 1 - i): (0,2), then (1,1), then (2,0).
diagonal = diagonal && is(i, i);
anti_diagonal = anti_diagonal && is(i, size - 1 - i);
}
// No row or column was full; only a diagonal can still make a line.
return diagonal || anti_diagonal;
}
How this code works: Board::has_line

A 3 × 3 board has eight possible lines: three rows, three columns, and two diagonals. has_line checks up to all eight in one pass of its outer loop, and stops as soon as it finds one.

The helper is. is(r, c) answers “does cell (r, c) hold this mark?”. An empty cell never matches.

“Assume yes, look for a no”. Each line starts with a flag set to true, and every cell on the line is combined into it with &&. One cell that does not match turns the flag false, and false && anything stays false. So after the last cell, the flag is true only if every cell matched.

One pass does three jobs. On step i of the outer loop:

  • the inner loop walks across row i, cells (i, 0), (i, 1), (i, 2), and down column i, cells (0, i), (1, i), (2, i). Swapping the two numbers, is(i, j) against is(j, i), is the whole difference between a row and a column;
  • if either is full, the function returns true at once;
  • then it checks one cell of each diagonal: (i, i) for the main diagonal and (i, size - 1 - i) for the other one.

The anti-diagonal. With size 3, size - 1 - i is 2, then 1, then 0, so the cells are (0, 2), (1, 1), (2, 0): top right to bottom left.

A worked example. X holds (0, 2), (1, 1), and (2, 0), as at step 8 of the trace below.

i row i full? column i full? diagonal after (i, i) anti_diagonal after (i, 2 - i)
0 no no (0, 0) is O: false (0, 2) is X: true
1 no no stays false (1, 1) is X: true
2 no no stays false (2, 0) is X: true

No row or column returned early, so the last line returns diagonal || anti_diagonal, which is false || true, which is true: X has a line.

Before calling the design finished, walk one scenario through it, step by step, writing down what changes. This verification trace finds mistakes that reading the code does not.

  1. play(X, 1, 1) → accepted; centre is X; turn → O.
  2. play(X, 0, 0) → refused, not your turn; nothing changes.
  3. play(O, 1, 1) → refused, cell taken; nothing changes.
  4. play(O, 0, 0) → accepted; turn → X.
  5. play(X, 3, 0) → refused, outside the board.
  6. play(X, 0, 2) → accepted; turn → O.
  7. play(O, 0, 1) → accepted; turn → X.
  8. play(X, 2, 0) → accepted; X has (0, 2), (1, 1), (2, 0), a diagonal; state → x_won. The turn does not change.
  9. play(O, 2, 2) → refused, the game is over.

The example program plays exactly this game, and its output is checked automatically:

Expected output
X at (1, 1): accepted
X at (0, 0): refused: not your turn
O at (1, 1): refused: cell already taken
O at (0, 0): accepted
X at (3, 0): refused: outside the board
X at (0, 2): accepted
O at (0, 1): accepted
X at (2, 0): accepted
O at (2, 2): refused: the game is over
O O X
. X .
X . .
result: X won

The tests check every rule, including the win on the last cell:

VerifiedCompiled and tested with GNU 11.4.0 and Clang 14.0.0 (C++20, 2026-12-01).

test_tic_tac_toe.cpp
// LLD_TEST(name) defines one test. LLD_CHECK(condition) records a failure
// if the condition is false, and LLD_CHECK_THROWS(expression, type) fails
// unless the expression throws that type of exception. They come from
// the site's small test header, lld_test.hpp.
LLD_TEST(x_starts_and_turns_alternate) {
Game game;
LLD_CHECK(game.current_player() == Mark::x);
LLD_CHECK(game.play(Mark::x, 0, 0) == MoveResult::accepted);
LLD_CHECK(game.current_player() == Mark::o);
}
// One game for each kind of line. Moves alternate X, O, X, O, ...
LLD_TEST(a_row_a_column_and_both_diagonals_win) {
// X takes the top row: (0,0) (0,1) (0,2).
LLD_CHECK(play_all({{0, 0}, {1, 0}, {0, 1}, {1, 1}, {0, 2}}).state() == GameState::x_won);
// O takes the middle column: (0,1) (1,1) (2,1).
LLD_CHECK(play_all({{0, 0}, {0, 1}, {1, 0}, {1, 1}, {2, 2}, {2, 1}}).state() ==
GameState::o_won);
// X takes the main diagonal: (0,0) (1,1) (2,2).
LLD_CHECK(play_all({{0, 0}, {0, 1}, {1, 1}, {0, 2}, {2, 2}}).state() == GameState::x_won);
// X takes the other diagonal: (0,2) (1,1) (2,0).
LLD_CHECK(play_all({{0, 2}, {0, 0}, {1, 1}, {0, 1}, {2, 0}}).state() == GameState::x_won);
}
LLD_TEST(a_full_board_with_no_line_is_a_draw) {
// X O X / X O O / O X X
const Game game =
play_all({{0, 0}, {0, 1}, {0, 2}, {1, 1}, {1, 0}, {1, 2}, {2, 1}, {2, 0}, {2, 2}});
LLD_CHECK(game.state() == GameState::draw);
}
LLD_TEST(a_win_on_the_last_cell_is_a_win_not_a_draw) {
// O X X / X O X / O O X: X's move into the last empty cell completes
// the right-hand column, so the game is won, not drawn.
const Game game =
play_all({{0, 1}, {0, 0}, {0, 2}, {1, 1}, {1, 0}, {2, 0}, {1, 2}, {2, 1}, {2, 2}});
LLD_CHECK(game.state() == GameState::x_won);
}
// Each refused move is tried after X has taken the centre; afterwards it
// is still O's turn, (0, 0) is still empty, and the game is still going.
LLD_TEST(refused_moves_change_nothing) {
Game game;
static_cast<void>(game.play(Mark::x, 1, 1));
LLD_CHECK(game.play(Mark::x, 0, 0) == MoveResult::not_your_turn);
LLD_CHECK(game.play(Mark::o, 1, 1) == MoveResult::cell_taken);
LLD_CHECK(game.play(Mark::o, 3, 0) == MoveResult::out_of_bounds);
LLD_CHECK(game.play(Mark::o, 0, -1) == MoveResult::out_of_bounds);
LLD_CHECK(game.current_player() == Mark::o);
LLD_CHECK(game.board().is_empty(0, 0));
LLD_CHECK(game.state() == GameState::in_progress);
}
LLD_TEST(no_move_is_accepted_after_the_game_ends) {
Game game = play_all({{0, 0}, {1, 0}, {0, 1}, {1, 1}, {0, 2}});
LLD_CHECK(game.play(Mark::o, 2, 2) == MoveResult::game_over);
LLD_CHECK(game.board().is_empty(2, 2));
}
// The Board on its own: misuse is a programming error, so it throws.
// mark_at is [[nodiscard]], so its unused result is cast to void, as in
// play_all, before LLD_CHECK_THROWS evaluates it.
LLD_TEST(the_board_rejects_a_taken_or_outside_cell) {
Board board;
board.place(0, 0, Mark::x);
LLD_CHECK_THROWS(board.place(0, 0, Mark::o), std::logic_error);
LLD_CHECK_THROWS(board.place(3, 0, Mark::o), std::logic_error);
LLD_CHECK_THROWS(static_cast<void>(board.mark_at(-1, 0)), std::out_of_range);
}

Goal: show that likely changes fit the design without a rewrite. You do not build them; you explain where they would go.

How: for each change, name the classes that would change and the ones that would not. A good design keeps each change in one or two places.

  • “Make the board size configurable, with a line of k to win.” Board takes the size and k in its constructor and stores the cells in a std::vector instead of a fixed array; has_line counts runs of k in four directions. Game’s rules do not change: it still asks has_line and is_full. Two lines of Game do change: it constructs its Board with the size and k, and in_bounds becomes an ordinary member function, called on board_, because the size is no longer a compile-time constant.
  • “Add undo.” Game keeps a history of accepted moves (a std::vector of row, column, and player), and Board gains clear(row, col). undo removes the last move, clears its cell, and restores the turn and the state. This is the Command pattern’s idea in its simplest form (PAT-14).
  • “Let a player play against the computer.” A new class chooses a move for a given board (choose_move(const Board&, Mark) -> cell). The game loop asks it instead of the person. Game and Board do not change: Game checks a computer’s move exactly as it checks a person’s.

Each change touches at most two classes, and none of them changes the order of the checks in Game::play. That is the evidence that the split between Game and Board was a good one.

The five steps are the short form of this site’s 12-step design workflow. For a real project, each step expands, and each expanded step produces a written artifact that someone can review:

Delivery-framework step Full workflow steps Taught in
1. Requirements 1 problem statement; 2 clarification questions; 3 requirements and constraints; 4 use cases and acceptance criteria Requirements section (REQ-01 to REQ-11)
2. Entities and relationships 5 domain modeling; 6 architecture and boundaries Modeling (MOD-01 to MOD-07, MOD-11), Architecture
3. Class design 7 responsibility assignment; 8 detailed design MOD-11, MOD-12, Principles, Patterns
4. Implementation 9 implementation; 10 testing C++ foundations, Testing
5. Extensibility 11 trade-off review; 12 evolution REQ-09, REQ-11, Testing and evolution

The full workflow adds what a timed session leaves out: a functional requirement list with sources, non-functional requirements such as speed and reliability, acceptance criteria traced to tests, invariants, and a recorded trade-off review. The order is the same, and so is the habit of going back a step when a later one shows a gap.

  • Use the five steps whenever you design something with more than one class: a feature, a small program, an interview problem, or the first version of a component.
  • Use the full workflow when the work will be built, reviewed, and maintained by others, when requirements come from several people, or when failure is expensive.
  • Skip most of it for a single function with an obvious contract. Write the requirement in a comment and the test, and move on.
  • Do not force the order when someone (an interviewer, a reviewer) asks about a specific step. Answer the question, then return to where you were.
  • Starting with classes. The first output should be a list of requirements, not a class Board.
  • No out-of-scope list. Without one, every “what about…” becomes a feature.
  • A class for every noun. Player, Cell, and Move classes with nothing to do make the design harder to read, not more complete.
  • Members without a reason. If no requirement needs a data member or a member function, leave it out.
  • Rules in the wrong place. If Game checks individual cells directly, or Board knows whose turn it is, a change to one rule spreads to both classes.
  • Skipping the trace. Many design mistakes appear only when you walk one concrete scenario through the classes.
  • Building the extensions. Step 5 explains how changes would fit; it does not implement them.

The person who set the problem adds: “End the game as a draw as soon as neither player can still make a line, so that players do not have to fill the board.”

Go back to step 1 and change requirement 4: a draw is now “no line is still possible for either player”, not “the board is full”. In step 2, nothing new appears: it is a question about the board. In step 3, Board gains bool has_open_line_for(Mark mark) const (true if some row, column, or diagonal contains no mark of the other player). Game gains no data member, but play changes: after a move with no win, it declares a draw when neither player has an open line, instead of only when the board is full. In step 4, the new function gets its own tests, including a board that is not full but cannot be won, and the existing draw test still passes (a full board with no line has no open line either). The framework tells you which output to update at each step.

Exercise: Put the outputs in order

These outputs come from one design session for a library’s book-loan system, in shuffled order. Put them in the order the delivery framework produces them, and name the step for each.

  • (a) “Loan remembers due_date_ because requirement 3 says a loan lasts 21 days.”
  • (b) “Out of scope: e-books, fines paid online.”
  • (c) “If the library adds reservations, a new Reservation class waits on a Copy; Loan does not change.”
  • (d) A sketch: Library owns 0..* Copy; Library owns 0..* Loan; each Loan refers to one Copy and one Member.
  • (e) Code for Library::lend and a trace: lend, then lend the same copy again, which is refused.
  • (f) “A member may hold at most five books at once.”
Show the explained answer

(f) and (b) in either order, then (d), (a), (e), (c).

  • (f) and (b) are step 1: a requirement and the out-of-scope list.
  • (d) is step 2: the entities and how they connect.
  • (a) is step 3: a data member justified by a requirement.
  • (e) is step 4: code for an important function and a trace.
  • (c) is step 5: how a likely change fits.

If you put (d) first, look again at what the sketch depends on: the entities come from the requirements, so step 2 cannot start until step 1 has produced them.

Exercise: Run steps 1 and 2 on a parking garage

“Design a parking garage that tells drivers whether there is space and charges them when they leave.”

  1. Write four clarifying questions, one from each group (core actions, rules, errors, scope), and an answer you would assume for each.
  2. Write a numbered requirements list (four to six items) and an out-of-scope list.
  3. List the nouns, and say for each whether it becomes a class, a data member or enum, a parameter, or nothing. Give a reason.
  4. Sketch the relationships: which class runs the main workflow, and who owns what?
Show the explained answer

There are several good answers; this is one.

1. Questions and assumed answers.

  • Core actions: “Do drivers take a ticket on entry and pay on exit?” → Yes, a ticket with the entry time; payment at the exit barrier.
  • Rules: “How is the fee calculated?” → A fixed rate per started hour, with a daily maximum.
  • Errors: “What if a ticket is lost, or the garage is full?” → A lost ticket pays the daily maximum; when full, the entry barrier stays closed.
  • Scope: “Several levels or sizes of space? Reservations?” → One level, one size, no reservations.

2. Requirements.

1. A driver entering gets a ticket with a unique number and the entry time,
if a space is free.
2. When no space is free, entry is refused and the sign shows "Full".
3. At the exit, the fee is the hourly rate for each started hour, at most
the daily maximum.
4. A lost ticket is charged the daily maximum.
5. After payment, the space is free again and the ticket cannot be reused.
Out of scope: several levels or space sizes, reservations, monthly passes,
the payment machine itself.

3. Nouns.

Noun Becomes Why
garage class Garage Holds free-space count and open tickets; enforces “full”
ticket class or struct Ticket Has a number and entry time; must be marked used
fee, rate, maximum class FeePolicy (or a function) The fee rule is likely to change, so keep it in one place
space a count in Garage Spaces are identical and unnamed (one size), so a number is enough
driver nothing Outside the system; no data is kept about them
barrier, sign interfaces (outside systems) Hardware the garage controls
payment nothing (out of scope) The payment machine handles it; the garage only learns “paid”

4. Relationships. Garage runs the workflow (entry and exit). It owns the open Tickets and uses a FeePolicy to compute the fee. It uses the barrier and sign through interfaces. If each space had a number or a size, Space would become a class; with identical spaces, it does not.

One gap to note: a lost ticket is paid at the daily maximum, but its open Ticket is never closed. With counted spaces the count is still right (the car leaves, the count goes up), but the garage keeps a ticket that will never come back. A good answer says how open tickets for lost tickets are closed, for example by looking them up by number plate, or after a time limit.

  • The delivery framework has five steps: requirements, entities and relationships, class design, implementation, and extensibility.
  • Each step has a written output, and you go back a step when a later one shows a gap.
  • Requirements include an out-of-scope list. Entities come from filtering nouns, not from turning every noun into a class.
  • Class design justifies every data member and member function with a requirement, and puts each rule in the class that owns its data.
  • Implementation checks a move before changing anything, and a trace verifies the design. Extensibility explains where changes would go without building them.
  • The five steps are the short form of the full 12-step workflow.