Thursday 19 May 2016

Command design Pattern in Java with Example

In simple words, Command design pattern is used to separate a request for an action from the object which actually performs the action. This decoupling between Invoker and Receiver object provides a uniform ways to perform different types of actions. This decoupling is achieved using a Command object, which is usually an interface with methods like execute(). The Requestor or Invoker only knows about Command object, and doesn't care of the actual object which process the request, which can be different. This transparency leads clean code on Invoker side and also enables opportunity to do several smart things on Command side. Your Command object can be as dumb as simply delegating request to Receiver and can be as smart as recording last command for performing UNDO and REDO functionality.
Read more »

No comments:

Post a Comment