nurselaine / typeracer

Typeracer Game
2 stars 1 forks source link

Remove UserCache semaphore from Server.java #7

Open michael-torkaman opened 6 months ago

michael-torkaman commented 6 months ago

All operations to shared resources should be limited to the GlobalContext class. Including operations on the the UserCache. such as adding, removing, creating, and etc... should be piped through semaphore protected functions defined in GlobalContext. This avoids further fragmentation of code/class logic. We can do it as is but might be a lot harder to debug and harder to read as more logic is added. I recommend removing the UserCache semaphore. unless there is something i missed.

nurselaine commented 6 months ago

I agree that we can move semaphores into global context. Although I don't necessarily think we need to move all logic that updates, adds, removes into global context. For encapsulation purposes it might be more practical to bundle data and behaviors or userlist and gamelist inside of its own object. It may allow for more maintainable and controllable code. Putting various modifiers from different classes into the global context may create greater dependency between the server objects and global context.