Difference between Strategy pattern and Command pattern

后端 未结 6 1509
一整个雨季
一整个雨季 2021-01-29 21:22

What is the difference between the Strategy pattern and the Command pattern? I am also looking for some examples in Java.

6条回答
  •  春和景丽
    2021-01-29 21:36

    I think a big difference here is that Strategy pattern is used when you need to shuffle between different objects that implement the same interface, but Command Pattern is used to shuffle between some objects that implement different interfaces ( as it encapsulates them into other objects called "Command Objects" ) and pass these command objects just like Strategy pattern does.

提交回复
热议问题