I study the strategy design pattern and from what I see, there is a very similar way to implement the "behaviors" of an object.
one way is the strategy design pattern. in this way the object 'has-a' strategy that represent the behavior.
the other way is to make this object 'implements' the behavior (interface).
for example, in a game, I have 'Enemy' object and one Enemy is flying and one is driving. so until now, I would think about: first 'Enemy' object implements Flyable and the second 'Enemy' implements Drivable. but another solution can be first Enemy 'has-a' FlyingStrategy and the second 'has-a' DrivingStrategy.
I'm trying to find the better solution in terms of good design.
Thanks.
Aucun commentaire:
Enregistrer un commentaire