Product design

Steam Families: share a library without occupying the whole library

Steam Families shares eligible games while keeping personal saves. Simultaneous play is limited by copies of each game: different games can be played together, while the same game requires enough copies.

Break down the problem and try your own design and implementation first. Then explore the reasoning to check states, edge cases, trade-offs, and ways to test your approach. The guide offers a reasoning path, not a complete implementation.

01
CODE EXERCISE

Count game copies and preserve each player’s progress

Implement an in-memory family game-lending module. The family owns two copies of X and one of Y; users are A, B, and C. Users can request to start a game, end their session, save progress text for that game, and read personal progress and free-copy counts. Each user can play at most one game at a time. Only someone currently playing a game can save their progress for it.

  1. Reject start requests if no copy is free or the user already has an active session; leave state unchanged. Ending a session returns its copy but preserves personal progress. Ending for a user with no active session changes nothing. Operations are sequential and all IDs are valid.
  2. A and B start X. C’s request for X is rejected, but C can start Y. A saves “Level 3” for X and ends: one X copy becomes free. B’s progress remains empty and A’s remains “Level 3.” While still playing Y, C’s request for X is rejected. After ending Y, C can start X; A’s progress is still unchanged.
  3. Deliver a runnable module and this sequence. Explain how copy occupancy and personal records are organized. No waiting queue, login, or persistence is needed.
Explore the reasoning

Separate three relationships: what each user is playing, how many copies of each game are occupied, and each user’s progress in each game. Decide which disappear when play ends and which must remain. C’s game switch and reads after A exits help detect accidentally locking the whole library or deleting personal data.