我已经阅读了命令模式,我想我错过了一些东西.Command对象的存在是为了抽象出Receiver对象的细节.在我看来,我们可以简单地停在这里,并保持对Command对象的引用,以在适当的时间执行适当的方法.
那么,为什么需要Invoker呢?这种额外的间接提供了什么优势?我们已经隐藏了命令后面的接收器的细节,那么命令随后被客户端隐藏的动机是什么?
abstraction information-hiding design-patterns command-pattern
abstraction ×1
command-pattern ×1
design-patterns ×1
information-hiding ×1