Java Reference
In-Depth Information
2.3.4
Separation of concerns
With typical JDBC code, it was not uncommon to find database resources such as
connections and result sets strewn throughout the application at all layers. We've
all seen the nasty applications with database connections and statements in JSP
pages, results being iterated over, and HTML in between it all. It's truly nightmar-
ish. In chapter 1 we discussed the importance of application layering. We saw how
the application is layered at a high level and also how the persistence layer is lay-
ered internally. i BATIS helps to support this layering by managing all of the persis-
tence-related resources, such as database connections, prepared statements, and
result sets. It provides database-independent interfaces and API s that help the rest
of the application remain independent of any persistence-related resources. With
i BATIS , you're always working only with true objects and never with arbitrary
result sets. i BATIS actually makes it hard to break layering best practices.
2.3.5
Division of labor
Some database administrators love their database so much that they won't let any-
one else write the SQL for it. Others are just so good at it that everyone else wants
them to write the SQL . Whatever the reason, it's always nice to leverage the
strengths in your development team. If you have someone who is particularly
good at writing SQL but not so hot at writing Java or C#, then let them write the
SQL unimpeded. i BATIS allows this to happen. Because the SQL statements are
largely separated from the application source code, SQL programmers can write
the SQL the way it was meant to be written, without having to worry about string
concatenation. Even if the same developers write both the Java code and the SQL ,
a common request from DBA s while performance tuning a database is “Show me
the SQL .” This is not an easy thing to do with JDBC , as the SQL is often wound up
in a series of concatenated strings or perhaps even dynamically built from a com-
bination of iteration and conditionals. With an object relational mapper the situa-
tion is even worse, as you usually have to run the application and log the
statements, and once you find them, you may not be able to do anything to
change them. i BATIS allows full freedom to enable anyone to develop, view, and
change the SQL statements run against the database.
2.3.6
Portability: Java, .NET, and others
i BATIS is a very portable concept. Because of its relatively simple design, it can be
implemented for nearly any language or platform. At the time of this writing, i BA-
TIS supports the three most popular development platforms: Java, Ruby, and C#
for Microsoft .NET .
Search WWH ::




Custom Search