Transaction script pattern

From CSSEMediaWiki
Jump to: navigation, search

The short definition for the Transaction Script Pattern is: “Organizes business logic by procedures where each procedure handles a single request from the presentation.”

When the Transaction Script Pattern is used, we see a business application as consisted of a number of transactions. The transaction could be viewing or changing some data, and also some application logic might be in the interaction between the application and the data store. With the Transaction Script Pattern, we build each transaction as a single method, then use the method to interact with database or database wrapping layers.

One benefit of using the Transaction Script Pattern is its simplicity nature; a procedure can be dedicated with one task without worrying others. Transaction script can be placed at any location within an application, the best solution is to separate the transaction script from others and put it into its own layer. Several transaction scripts can be put into one class or we can use one class for each transaction script with using the Command pattern.

When To Use It

The Transaction Script Pattern should be used when the application itself does not have much logic, or it does not have much overhead in performance and understanding. As the business logic getting complex, other patterns such as Domain model pattern is a better choice.

Personal tools