Java Reference
In-Depth Information
savePendingOrder() method, which takes a PendingOrderDTO as a parameter and
saves it in the database.
The transaction scripts also return the DTO s, such as PlaceOrderResult and
UpdateDeliveryInfoResult , to the presentation tier. These DTO s contain a status
code and other DTO s, such as PendingOrderDTO .
This design has a simple structure, which is a distinctive feature of a Transac-
tion Script pattern-based design. The majority of the code is in the transaction
scripts and the DAO s. You may have noticed that the names of the DTO s, which
are simple data holders, are similar to the names of the domain model classes that
we implemented in chapter 3. It is important to remember that they contain only
data and do not implement any other behavior. As you will see later, the simplicity
of this pattern is both a blessing and a curse.
9.1.2
Benefits and drawbacks of the Transaction Script pattern
The Transaction Script pattern has the following benefits and drawbacks.
Easy to use
One of the most appealing aspects of the Transaction Script pattern is that it is
easy to apply because you don't need to have OO design skills. You just have to
write a transaction script method to handle each request. Similarly, to implement
a new business logic feature you typically have to add some code to an existing
transaction script. In comparison, to use the Domain Model pattern you must
have object-design skills and know how to identify classes and assign responsibili-
ties to them.
Can use full range of SQL features
Another benefit of the Transaction Script pattern is that it can sometimes improve
performance significantly because transaction scripts can access the database
using the full range of SQL features. An application can use SQL to efficiently
query the database in ways that are not supported by persistence frameworks such
as JDO and Hibernate. This can be especially important when you're working with
a legacy schema. In addition, SQL' s ability to perform bulk updates and deletions
is far superior to those capabilities provided by some persistence frameworks. As a
result, it's not uncommon to implement some parts of an application using the
Transaction Script pattern and SQL .
Code can be difficult to understand and maintain
The simplicity of this pattern is a double-edged sword. Because you do not have to
do any OO design, all of the business logic is concentrated in the transaction
 
 
 
 
Search WWH ::




Custom Search