mercredi 9 décembre 2015

Pattern for Delegating Calls based on A Given State

I'm trying to think of a pattern I can use.

I want to be able to have a middleman module that takes in a kind of state of a game. Given that state, call a certain method that resides in anotehr module.

What pattern could I use for this?

For example, I want to be able to take in a state of "computer always wins" and based on that state type, I'll call someOtherModule.makeComputerMove(). In the future maybe we want to be able to set the game to a mode where the computer doesn't always win. Well then we could send in a state of "normal game" or something like that which would just call computerAlwaysWins.makeComputerMove() from a different use case module such as normalGame.makeComputerMove()

get the idea?

I can't think of any patterns to provide such a thing...probably because I don't know a lot of them.

Aucun commentaire:

Enregistrer un commentaire