Phase 1: Requirements & Use Cases
Interviewer: "Design a Chess game."
Candidate: "Sure. Let me clarify scope before modeling anything. I'm thinking of a two-player, single-board Chess game that enforces standard FIDE rules: piece movement, turn alternation, check/checkmate/stalemate detection, and win/draw conditions. Are we also covering special moves like castling, en passant, and pawn promotion?"
Interviewer: "Yes, all standard rules. What else do you want to confirm?"
Candidate: "A few things. First — is this a human vs. human model, or do we need an AI opponent? Second — do we need move history and undo capability, or just current game state? Third — are we building a GUI or purely a domain model that a UI layer could consume? Fourth — do we need to detect draws by threefold repetition and the fifty-move rule, or just stalemate?"
Interviewer: "Human vs. human, move history with undo, domain model only, and handle stalemate and insufficient material draw — skip threefold repetition for now."
Candidate: "Perfect. The actors are
Player(White and Black, each making moves) andChessGame(the orchestrator enforcing rules and game state transitions). The core use cases are: (1) initialize a game — place all 32 pieces on the starting squares; (2) make a move — a player selects a piece and a destination, the game validates the move, applies it, and switches turns; (3) detect check — after every move, determine if the opponent's king is under attack; (4) detect checkmate or stalemate — if the active player has no legal moves, determine which; (5)…
In the full tutorial
- Phase 2: Object Modeling
- Phase 3: Class Design & Relationships
- Phase 4: Design Patterns Application
- Phase 5: Key Implementation
- Phase 6: Extensibility & Trade-offs