mardi 24 novembre 2015

Chain of Responsibility vs Events

I always have the doubt when it's came to chose one of these 2 patterns. For example: Let assume that I have an input manger and when I press the one button, I want the main player to execute the jump action. In this case, I can use 2 different solutions:

  1. I have one input the inputManger that tells the GameManger what just append and the gameManger tells the Player-manger to act. So it's something like: inputManger ---> Game manger ---> Player-manger and this is the Chain of Responsibility pattern.
  2. the PlayerManger register the jump event on the inputManger i receive the input and the PlayerManger automatically execute his jump routine.

So my question it's: Why would I choose one pattern ove the other? Both have their pro an cons, so witch are you common choices when you have this kind of situations?

Aucun commentaire:

Enregistrer un commentaire