. NET design Pattern Instance command pattern

Source: Internet
Author: User

Introduction to Command mode (Brief Introduction)

Command pattern encapsulates the request as an object, allowing you to parameterize clients with different requests, queue or record request logs, and support revocable operations.

Encapsulate a request as an object, thereby letting your parameterize clients with different requests, queue or log request s, and support undoable operations

Ii. issues addressed (What to Solve)

Consider using command mode when you need to have a undo or redo operation.

Command mode Analysis 1, Command mode structure

Command abstract class: declares an interface for performing operations, declares an interface for executing a operation.

Concretecommand implementation class: Binds a Recipient object to an action. Invokes the corresponding action of the receiver to implement execute.

Defines a binding between a Receiver object and an action

Implements Execute by invoking the corresponding operation (s) on Receiver.

Receiver class: Know how to perform a request-related operation. Knows the perform the operations associated with carrying out the request.

Invoker class: Requires the command to execute a request. asks the command to carry out the request.

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.