Java Reference
In-Depth Information
specialized services, such as transaction support, security, and connection
management. Applications can then use the EIS interfaces directly or through
common web application server interfaces. With this common connection
framework, the context of a connection can be maintained to achieve unprec-
edented compatibility, transaction support, and interoperation between appli-
cation components.
Antipattern: Split Cleaners
In chapter 6 , several antipatterns involve the conservation of resources. While
the following antipatterns are not specifically memory related, we can see similar
themes. One such antipattern is the Split Cleaner, presented by Eric E. Allen in
an article titled “Diagnosing Java Code: The Split Cleaner Bug Pattern.”
Figure 7.5 shows the scenario. We have an application that has a multistage pro-
cess. Each stage of the process is managed by a different object, or at least in a
different method. Each stage of the process will need access to some connec-
tion. We must create and free the connection somewhere in the application.
One way to solve the problem is to manage the connection inside one or more
of the process stages, passing the connection as a parameter. Consider this little
application. The application needs to compute first the total cost and then the
tax for the items in a shopping cart. To do this, it takes a two-phase process:
adding the total costs in one process, and adding the total tax in another.
do Part 1
do Part 2
Figure 7.5 This is a UML sequence diagram showing the Split Cleaner antipattern. The resource
is allocated and freed in a different place. Future enhancements can easily lose the cleanup for
the connection, creating a bug.
Search WWH ::

Custom Search