Answer the question
In order to leave comments, you need to log in
What is the best way to convert a factory method?
Good afternoon.
There is a .NET program that implements a turn-based multiplayer game. It contains the Game class, with the GameStateChanged, GameEnded events.
The game is created like this:
CurrentGame = GameFactory.CreateGame(_gameMeta, activePlayer, true);
CurrentGame.GameEnded += OnCurrentGameEnded;
CurrentGame.GameStateChanged += OnCurrentGameStateChaged;
Answer the question
In order to leave comments, you need to log in
The correct way is to throw out the mandatory launch of the game. For example, by adding a named parameter with a default value.
Passing delegates to a factory method is already an extreme case, if it has come to this - it's time to change the architecture of the code, moving away from events.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question