Command mode-behavior design mode 2

Source: Internet
Author: User

1. commands encapsulate a request as an object so that you can parameterize the customer with different requests, queue requests or record request logs, and support unrecoverable operations. The command mode is related to life. Combined with the object-oriented thinking, there should be at least four classes: the command sender, the command receiver, and the command itself. Some may say that the command transmitter is redundant. Is it redundant? Why add a command transmitter? The command transmitter can be used not only to pass commands! First, extract an example from the Life: the hotel waiter is just a command transmitter in the mode. Imagine what would happen if there were no waiters in the hotel? The customer needs to place orders directly with the cook. No matter whether the food is ready or the food is not, the cook has to find a specific customer. What should I do if there are more customers? Do the chefs remember? I'm afraid he's too busy to cook his own food. Remember who ordered it! This is not complete yet. The customer wants to change the order and want to change the food. The chef is starting to grow. Which table is the food, which table is missing ...... What is the task of a hotel attendant? 1. Sort out customer orders-add, delete, and modify. Orders may need to be modified or deleted due to customer or hotel reasons. 2. Record the order 3. Send the sorted order to the cook. In this way, he only needs to cook the food according to the order given by the waiter. What changes are there in the process, and the waiter also manages the order. If there is no such dish, he only needs to pass it to the customer through the waiter and change it in time. It seems that in command mode, the passer is essential. The rest of the commands were issued by the sender and receiver, all performing their respective duties, and the system was running. Ii. Category chart

Related Article

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.