vendredi 26 mai 2017

What is the simplest Event design pattern

Lately, I've been pondering about the following problem for a while. For the code bellow, what is the easiest way to modify Game::counter via Event::Perform() method which is called from Game class? I considered Observer and Command design patterns, but it seems that there is a much simpler way to do this.

class Game
{
public:
    Game();
private:
    int counter;
    vector<Event*> Events;
};

class Event
{
public:
    virtual void Perform() = 0;
};

Thank you

Aucun commentaire:

Enregistrer un commentaire