Design a two-player board game. Start with Tic-Tac-Toe: players take turns placing a symbol, the game checks for a win or a draw. Then show how the design grows into Chess, where every piece moves by its own rules.
Name the players, the board and its cells.
We know the game but have no objects. Where do moves live, and who knows what a cell holds? A `Player` has a name and a `Symbol`. A `Board` owns an N by N grid of `Cell`s and can place a symbol (refusing an occupied cell) and say if it is full. The board only knows about pieces on cells. It has no idea who is winning, so the same board class can later hold Chess pieces. Cells as objects use more memory than a plain 2D array of characters. For a 3 by 3 board that is irrelevant, and a cell can later carry a chess piece.
Run the turns and track the status.
Nothing enforces whose turn it is, or what happens after a move. `Game` holds the board, the two players, whose turn it is and a `GameStatus`. `play(row, col)` places the current player's symbol, updates the status and passes the turn. Every turn runs the same steps in the same order: check the game is still running, place the symbol, check for a result, switch player. That fixed order is the **Template Method** idea. At this point `Game` would have to contain the win maths. That is the next problem to solve, because it will grow with every new rule.
Keep the win checking out of Game and the board.
`Game` would need row, column and diagonal checks, and a new variant (four in a row) would mean editing it again. A `WinStrategy` interface with `isWin()`. `RowColumnWin` and `DiagonalWin` implement it, and `Game` holds a list of them and asks each after a move. Each rule only looks at the row, column and diagonals the last move touched. This is **Strategy**: new rules are new classes, and `Game` never changes. Checking only the lines through the last move makes each win check cost N, not N squared. A list of rules means we ask several questions per move. That is fine for a small board, and each rule stays tiny and easy to test.
Show the same design holding pieces with their own rules.
In Chess every piece moves differently. Putting those rules in `Game` or `Board` would create a huge `if piece == ...` chain. A `Piece` base class with `canMove(board, from, to)`. `Rook`, `Bishop` and `Knight` override it with their own movement. A `Cell` can hold a piece. King, Queen and Pawn follow the same pattern. Each piece knows its own rule, so adding a piece is one new subclass (**polymorphism**). `Game` just asks `piece.canMove(...)` before applying a move. Win rules become 'is the king in checkmate?', a new `WinStrategy`. Inheritance fits here because piece types are fixed and differ only in movement. Rules that depend on other pieces (blocking, check) still need the board, so pass it in rather than letting pieces reach for it.