Skip to content

Instantly share code, notes, and snippets.

@workze
Last active April 24, 2020 04:43
Show Gist options
  • Save workze/eead3ad1ff56241d857eb4941d0d5b3f to your computer and use it in GitHub Desktop.
Save workze/eead3ad1ff56241d857eb4941d0d5b3f to your computer and use it in GitHub Desktop.
设计模式 命令模式

https://design-patterns.readthedocs.io/zh_CN/latest/behavioral_patterns/command.html

要旨: 逻辑对象,方法很多。 客户端需要操作逻辑对象的方法。 将逻辑对象的方法,或者多个方法,封装到一个类中-命令类。即在该类中执行逻辑对象的各种方法。 客户端只需要创建对应的命令类即可。

为了解耦,又引入了代理层去触发逻辑对象-命令的调用。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment