Delivery Framework

Requirements (5 minutes)

Think around these points

  1. Primary capabilities — what can this app do?
  2. Rules and completion — what's the rules define success, failure, state transition?
  3. Error handling — How should the system respond to inputs or actions when it's invalid
  4. Scope boundary — What are are in scope, what's out of scope

Example

Requirements:
-- Primary capabilities
1. Two players alternate placing X and O on a 3x3 grid.
-- rule and completion
2. A player wins by completing a row, column, or diagonal.
3. The game ends in a draw if all nine cells are filled with no winner.
-- error handling
4. Invalid moves should be rejected (placing on an occupied cell, acting after the game is over).
-- scope boundary
5. The system should provide a way to query current game state and reset the game.

Out of Scope:
- UI/rendering layer
- AI opponent or move suggestions
- Networked multiplayer
- Variable board sizes (NxN grids)
- Undo/redo functionality

Entities and relationship (3 minutes)

We need to do 2 things

  1. Identity entities — what are the main actors
  2. Define relationship — what related together
    1. Which entity is the orchestrator?
    2. Which entities own durable state?
    3. How do they depends on eachother?

For example in here we will have

Entities:
- Game
- Board
- Player

Relationships:
- Game -> Board
- Game -> Player (2x)

Class design (10-15 mins)

Start with the orchestrator (for tictactoe is Game) then move down to support entities (Board, Player)

For each one, answer 2 questions

  1. State: what does this class need to remember or enforce the requirements
  2. Behavior: What does this class need in terms of operations

We need to stay discipline in tying state to behavior, this way to avoid bloat and guessing

Derive state from requirement

For Tic Tac Toe, here's how this works for Game:

RequirementWhat Game must track
"Two players alternate placing X and O on a 3x3 grid."The two players, whose turn it is, and the Board
"The game ends when a player wins or the board is full."Game state (in progress, won, draw) and the winner (if any)
Game – State:
- board: Board
- playerX: Player
- playerO: Player
- currentPlayer: Player
- state: GameState (IN_PROGRESS, WON, DRAW)
- winner: Player? (null if no winner)

Then repeat this process for the other entities in your system.

Derive behavior from requiremetns

Once we got the state,