Bird
0
0
LLDsystem_design~3 mins

Why Extensibility (NxN board, multiple players) in LLD? - Purpose & Use Cases

Choose your learning style9 modes available
The Big Idea

What if your simple game could grow to support endless players and board sizes without breaking?

The Scenario

Imagine you built a simple game with a fixed 3x3 board and just two players. Now, you want to add more players and a bigger board, like 5x5 or 10x10. You try to change every part of your code manually to fit these new rules.

The Problem

Changing every piece of code for each new board size or player count is slow and confusing. You might miss some places, causing bugs. It becomes a big mess to maintain and update, especially as the game grows.

The Solution

Extensibility means designing your game so it easily supports any board size and any number of players without rewriting everything. You build flexible parts that adapt to changes, making your code clean and easy to grow.

Before vs After
Before
board = [[None]*3 for _ in range(3)]
players = ['X', 'O']
After
def create_board(size):
    return [[None]*size for _ in range(size)]

players = ['X', 'O', 'Y']  # any number
What It Enables

Extensibility lets your game grow smoothly from a tiny 3x3 board with two players to a large NxN board with many players, without headaches or bugs.

Real Life Example

Think of a chess app that started with just classic chess but later added variants like 4-player chess or bigger boards. Extensibility made these upgrades possible without rebuilding the app from scratch.

Key Takeaways

Manual changes for each new board or player count cause errors and slow progress.

Extensible design adapts easily to new sizes and players.

This approach saves time and keeps your code clean and maintainable.