I am currently programming some kind of event discrete simulation. I have two classes: SimulationPlayer
, that basically just plays out all of the simulation events on the SimulationSubject
. SimulationSubject
is an object, that is modified by all the SimulationEvents, that are played out sequentially.
Then there are multiple different simulation events SimEventA
, SimEventB
, SimEventC
and so on.
All the simulation events are in a List and SimulationPlayer
takes the next one, and calls a function play(SimulationSubject s)
on that event. That play function is implemented differently on every SimEvent class of course.
Now this means the SimulationSubject class is modified in the scope of the respective function, which is bad practice.
Is there any design pattern that solves this kind of scenario?
Aucun commentaire:
Enregistrer un commentaire