Design Mode: Command mode

Source: Internet
Author: User

I read the blog of Yunfei Longxing, which is very good.

Http://www.cnblogs.com/sjms/archive/2010/07/09/1774069.html

 

The customer only sends commands (requests), and the customer does not care who accepts them and how to execute them.

Definition: encapsulate a request (command) as an object.

Command mode is the encapsulation of commands. The command mode separates the responsibility for issuing commands from the responsibility for executing commands and delegates them to different objects.

Each Command is an operation: the Requesting Party sends a request to execute an operation; the receiving party receives the request and performs the operation.

The command mode allows the requester and the receiver to be independent, so that the requester does not have to know the interfaces of the receiver,

You do not need to know how the request is received, whether the operation is executed, when it is executed, and how it is executed.

 

Command mode: You need to define a command interface to constrain all command objects. And provides specific command implementation.

Each command implementation object is a specific encapsulation of a client request(Although it is a virtual implementation)

Each button of the chassis corresponds to a specific command implementation.

The command object does not know how to handle the command. He holds a command ReceiverCycler, Which is implemented by the aggreger.

In command mode: command and receiver are not inherent.Client completedCommandAndCycler.

Invoker: the requester holds a reference to the command object.

There are many buttons on the chassis. The chassis is invoker.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.