This is an image from an old exam I'm working through. Through the UML-diagram, as seen above, how can I determine if this is Command Pattern or Strategy Pattern?
The answer to the question is that is is Command Pattern and Composite Pattern. Clearly, it is Composite because of Block have multiple aggregations for Statement. I understand that it is Command Pattern since they use execute() in an interface which then is implemented in several subclasses, altough couldn't this technically also be seen as Strategy Pattern?
I don't really understand the difference between the two of them in concrete code, as I tend to see it as the same code just used in different ways, thus an UML-diagram would therefore be able to be either Pattern. In this case though, answering Strategy would give less points than Command Pattern.
Aucun commentaire:
Enregistrer un commentaire