My opinion on Command mode (behavior mode)

Source: Internet
Author: User

I think the essence of command mode is to isolate the trigger from the receiver, to elevate a function capable to the level of the class. A base class containing virtual functions Excute () do a lot of specific receiver class C**command (), in the specific receiving class to implement Excute, And the trigger invoke contact is the base class, the use of polymorphism, the real director is the specific recipient class, so isolated, no matter how many specific recipient class, both code is not affected very flexible

Many Linux software can support both UI operations and command letter operations. You must use the command mode.

The command mode actually decouples the software from the real business logic and UI

advanced features such as transaction rollback can also be supported after the command is instantiated
The logs recorded in the SQL database are the command that is recorded. Rollback to a database transaction.

Computer software Science is to add the indirect layer to achieve abstract science.

Of course, every additional layer of indirection software will be more complex. So this is actually a degree of problem, not the more loosely coupled, the more modular things the better. See the actual problem solved. Strong-coupled code readability is the best.

My opinion on Command mode (behavior mode)

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.