Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Another day another architecture problem.

So my engineer submitted some code the other day where passing a reset data command to our data system would reset both the session data and the player's saved data. One command doing different things with the vague notion of data. Seemed like a Single Responsibility Principle (SRP) smell.

First step is decoupling the two. Now a reset only touches what's in session memory, and the save system can be configured independently in regards to its saving behavior, so our data system doesn't force it on anyone. If you want to wipe the save, that's its own call.

Next I realized data is such a poor name for a system, it's so vague. Everything is data. "Reset data" could mean anything, which is kind of how this happened in the first place. So we looked at it and found it could be split into two systems: definitions, which holds the read-only static templates, and state, which holds the mutable copies the game actually changes. Now if you send a reset to state, it only resets the mutable session data.

Lesson: Consider your assumptions. The name was telling us something we never questioned.

Question: How do you manage data and saving in your game?