When One Player Became Four Concepts
While redesigning Golden Army using SwiftUI and GoldenPlatformCore, the initial assumption was straightforward:
local player sits at the bottom
remote player sits at the top
red moves first
black waits
As more games and networking scenarios were considered, these assumptions began to conflict with one another.
The breakthrough came after realizing that several different ideas had been accidentally merged together:
local vs remote
red vs black
active vs waiting
top vs bottom
A player could be:
local
black
sitting at the bottom
waiting for the opponent
These properties were independent.
The architecture evolved into four separate concepts:
GTTableSide
top / bottom
Player
red / black
GTSeatState
active / waiting
sessionMode
host / participant
The framework became responsible for seating and presentation.
The game became responsible for colors and rules.
Networking became responsible for connections.
Many software problems appear difficult because several independent concepts have become coupled together.
Good design often begins by discovering that what seemed to be one thing is actually several different things.