I am creating a small game as a training exercise to create an application using Event Sourcing as a save mechanism.
One problem that I am currently facing is a very primitive obsession in my application.
Player is a central concept, player names must be unique, so I used PlayerName as an identifier for events in my game. This is a string.
Until that moment, I left with event handlers that could store a list of player names (in the form of strings) to represent the players in the game and their various states. However, the last important role that I added to the game required me to make changes in several places (and not just one). I left it a bit before introducing some "real" objects.
The problem I am facing right now is that every event handler that deals with an event related to a player (or several players) requires a kind of search to find and find the Player object matching the value of PlayerName .
It seems that there will be a lot of duplication in the handlers now, since they need to go and "Get" different players from the search (until this moment I had no getters / setters on my domain objects, I think it's worth spending money to remove a primitive obsession but I would like the solution not to require from me).
It seems to me that I missed a piece of the puzzle, but I'm struggling to put it on.
source share