Enterprise design mode Reading Notes Transaction Script

Source: Internet
Author: User

Transaction Script



Features: A Transaction Script puts all the things it has to do together and does it by itself (there is no message chain, except to call a more underlying database operation ). For example, if you want to book a room, you can check whether there is a vacant room, calculate the rent, and update the database. All the operations are done by yourself and put them in a function. Similar to procedural programming.

 

Advantages:

1. Simple. High Performance and easy to understand.

2. The processing of one transaction will not affect other transactions.

 

Disadvantages:

It is difficult to process complicated logic. If you find a lot of repeated code in different Transaction scripts, it means the Transaction Script Mode is insufficient.

 

Note:

Separate Transaction scripts to at least different functions, and separate them from UI and database operations (different classes and packages ). And because it is located in the middle layer, there should be no method to call the UI.

Transaction Scripts has two methods to organize the class structure.

1. Put several Transaction Scripts in a class, which are logically related.

2. Each Transaction Script corresponds to a class, which can apply the Command mode, but it does not seem necessary.

 

Involved mode:

The database modes used in Transaction scripts are usually Table Data Gateway and Row Data Gateway.

I am sorry to keep it on the homepage. Thank you for your advice.

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.