Command Pattern

Object Oriented Programing

Command Pattern

 

The Command pattern is one of the design patterns that allows you to isolate the portion of code that performs an action (possibly very complex) from the code that requires it to run; the action is encapsulated in the Command object.

The goal is to make the action of the client different but without knowing the details of the operation itself. Another important aspect is that the recipient of the request may not be statically decrypted when executing the command but executed at execution time.

In this pattern we create a Parent for each process to handle and child classes for each command to execute in the process.

Each command class have a sender(Send) and Execution(DO) method. The DO is Override method.

All command for process to execute, shall be create like a child classes.

To Send a message, use a queue that is created by the ParentClass Data.

The dispatcher use the deque of class in the DO method.

Like you see the future modification don’t require to vchange the code inside the dispatcher, but only adding a class or modify from the project, then by placing the event to send action and in the project where the action is created with a child class.

This design technique is fast to build spec if you use GOOP toolkit from PAckageManager.

 

 

%d blogger hanno fatto clic su Mi Piace per questo: