In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will share with you the relevant knowledge about what the motivation of web command mode is. The content is detailed and the logic is clear. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
Intention
Encapsulate a request as an object for construction, delivery, and invocation. The request here can be an action or transaction.
motivation
Sometimes you know that you need to submit a request to some recipients, but you don't know which recipient you want to submit the request to. Here are some examples of menus that appear in many applications. When designing menus, although you know exactly what needs to be done, the data that operates on these menus may not have been generated yet.
The solution begins by defining the abstract class Command that encapsulates the menu action, which defines the Execute operation that performs the action. In an Execute operation like the Command class, the recipient executes the request. A common practice is to manage the recipient as an instance variable that represents a Command class (a data member in C++).
The figure above is an example of using Command in the application menu function. Application manages one Menu instance, while the Menu instance manages several MenuItem instances. Each MenuItem represents a menu item. At the same time, Application also manages an instance of Document to express the open document.
In order to dynamically configure menu items, the software allows each MenuItem to hold an instance variable of type Command. When the user selects a menu item, the corresponding MenuItem calls the Execute method of the corresponding Command object. Because the type of the Command member is the base class type, MenuItem does not know which subclass the Command member belongs to.
Another function of OpenCommand is to open a new document for Application. Its recipient is Application itself, which is the first object created in the entire application. When Application creates the MenuItem, it can pass its own reference directly as an argument to the constructor of the OpenCommand. When the user selects the OpenDocument menu item, OpenCommand calls the method of Application in his Execute method to open the new document.
PasteCommand and OpenDocument, the representational classes of Command, have the same Execute interface, but perform completely different operations on different recipients internally.
These are all the contents of the article "what is the motivation of web command mode?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.