본문 바로가기
Computer Science

Design Patter - Command Pattern

by OKOK 2021. 7. 29.

Command Pattern

  • Purpose
    - Encapsulates a request as an object.
    - This allows the request to be handled in traditionally object based relationships such as queuing and callbacks.
  • Use When
    - Requests need to be specified, queued, and executed at variant times or in variant orders.
    - A history of requests is needed.
    - The invoker should be decopupled from the object handling the invocation.

  • Every time you want to modify the behavior of a button, you need to touch the client code.
  • Encapsulates a request as an object.

 

  • We can see that the receive and ivkoker are decoupled.
  • This pattern is useful when operating multiple devices with the remote control.

 

 

  • Command decouples the object that invokes the operation from the one that knows how to perform it. 
  • Commands cand be manipu;lated and extended like any other object.
  • You can aeemble commands into a composite command.

'Computer Science' 카테고리의 다른 글

Things to think about when designing a sofware structure  (0) 2021.07.29
Visitor Pattern  (0) 2021.07.29
Design Pattern - Strategy Pattern  (0) 2021.07.29
Design Pattern (2)  (0) 2021.07.28
Design Pattern (1)  (0) 2021.07.28

댓글