Using Command Design pattern

后端 未结 6 1146
误落风尘
误落风尘 2020-11-27 18:26

Can any one explain with simple example of Command Pattern. I refer in internet but i got confused.

6条回答
  •  感动是毒
    2020-11-27 18:34

    Command Design Patterns decouples invoker of service and provider of service. In general scenario, say for eg., If Object A wants service of Object B, it'll directly invoke B.requiredService(). Thus, A is aware about B. In Command pattern, this coupling is removed. Here, there's an intermediate object known as Command, which comes into picture. Thus, A deals with Command object and command object deals with actual object B. This approach has several applications such as designing applications, which are :-

    • Accepts commands as requests.
    • Undoing requests.
    • Requests requests.
    • Creating macros.
    • Creating Task Executors and Task Managers.

    For more information regarding, Command Design Pattern, I'll recommend https://en.wikipedia.org/wiki/Command_pattern. For all other design patterns, refer to https://www.u-cursos.cl/usuario/.../mi_blog/r/head_first_design_patterns.pdf

提交回复
热议问题