两种设计模式都封装了算法,并将实现细节与其调用类分离.我能辨别的唯一区别是策略模式接受执行参数,而命令模式则没有.
在我看来,命令模式要求所有执行信息在创建时都可用,并且它能够延迟其调用(可能作为脚本的一部分).
什么决定指导是使用一种模式还是另一种模式?
encapsulation design-patterns strategy-pattern command-pattern
command-pattern ×1
design-patterns ×1
encapsulation ×1
strategy-pattern ×1