Skip to content

Enforce layer separation: route GUI database calls through logic layer #55

Open
francinv opened this issue Apr 6, 2026 · 0 comments
Open
Assignees

Comments

@francinv
Copy link
Member

francinv commented Apr 6, 2026

Screen helpers bypass the game logic layer and call DatabaseManager directly.

Files that violate layering:

  • LobbyValidator.java:5
  • LobbyFlowController.java:5
  • SetupFlowController.java:5
  • GameNetworkHandler.java:8

What to do:

  • Move database interactions into states/ or new service classes in model/
  • Screen helpers should call logic-layer methods instead of DatabaseManager.getInstance() directly
  • After fix: grep -r "DatabaseManager" screens/ should return zero results

Ref: Architecture doc claims strict one-way GUI → Logic → Database layering.

@francinv francinv assigned francinv and unassigned francinv Apr 6, 2026
francinv pushed a commit that referenced this issue Apr 6, 2026
Route all database calls through state classes instead of calling
DatabaseManager directly from screen helpers.

- LobbyState: add validateLobby, listenForOpponentReady, startGame,
  listenForGameStart wrapper methods
- SetupState: add confirmSetup, unconfirmSetup, listenForBothSetupReady,
  getOpponentBoard, getFirebaseApi wrapper methods
- LobbyValidator: route through LobbyState instead of DatabaseManager
- LobbyFlowController: route through LobbyState
- SetupFlowController: route through SetupState
- GameNetworkHandler: accept FirebaseAPI via constructor injection
- Thread LobbyState through MainMenuScreen→MainMenuUI→JoinGamePanel
- Thread FirebaseAPI through SetupScreen→GameScreen→GameNetworkHandler

Result: zero DatabaseManager references in screens/ package
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant