What is it
Many business applications can be seen as a series of transactions, each of which can be processed by using a Transaction Script.
HOW it works
With Transaction Script, we can focus on handling every transaction without having to consider the impact of other transactions, which is to get input, query the database, handle transactions, save results.
Transaction Script can have two ways to organize a category. One is to put several Transaction Script in the same field in a separate class; the other is to use the Command mode, organize each Transaction Script into a subclass of a Command base class; of course, do not organize becomings And use global functions, but the way the class is more likely to isolate data.
When to use it
Transaction Script The biggest advantages and disadvantages are its simplicity. The advantage is that the code is simple and easy to understand, and the operation efficiency is also good; the disadvantage is that the code repeats are likely to have a repetition. Of course, this can be reduced by reconstruction. As the complexity of business transaction, Transaction Script will become The force is not from the heart.
The development of the Transaction Script has the following features: Object classes only include data, excluding any transaction-related algorithms, often the type of table structure in the database; calling SQL statements often appear in the Transaction Script core function, of course this is not Good design, should be used, such as Table Data Gateway, etc., encapsulate SQL statements in Wrapper to perform database interactions, and the core function directly accesses the Wrapper method for transaction processing.