Bitter EJB
However, every coin has two sides: the other side of "freedom of choice" is "complexity". Although EJB is an incredibly powerful tool in the hands of experience architects, it is subject to a lot of misuse by novice developers who do not make sound choices. For example, some developers might use a BMP entity bean to map each database table in the system; or access entity beans directly from a distributed layer; or store large amount of data in session objects ... The list goes on. Although those approaches are technically possible, they are hardly the most efficient ways in most cases. Such problems have not only caused many projects to fail but also tarnished EJB's reputation. In fact, the complexity of EJB is often quoted as an argument for other enterprise platforms.
For EJB developers, it is crucial to learn from other people's experiences and follow proven best practices. That helps to reduce the complexity of the platform. Manning's "Bitter EJB" is a very timely book written by well-known experts in the EJB field: Bruce Tate, Mike Clark, Bob Lee and Patrick Linskey. Unlike other "architectural" books, Bitter EJB teaches best practices through common mistakes (anti-patterns). It focuses on "what not to do" but still encourages developers to come up with liberal (everything not forbidden is OK) and innovative solutions. After all, EJB is about flexibility and freedom of choices.
Part I of the book is an overview of anti-patterns in the EJB specification. The EJB specification itself has several major design problems when it first came out in March 1998. EJB v1.1 and v2.0 have gone great length to fix the anti-patterns in the specification. But early adopters may have already developed some anti-patterns in their applications. For new developers, the history also serves as a valuable lesson on what EJB is really for and how different components in the specification fall into their current places. In this part, the authors also provide an excellent recount on what went wrong in the high profile TSS Java PetStore benchmark.
Part II is about session and message-driven beans. Those beans are mainly used in the integration layers. Topics covered in this part include how to deal with large database results, whether to maintain session states, the limitations of XML and much more.
Part III covers EJB persistence. Entity EJBs are probably the most confusing types of components. Many experts have advocated to abolish entity EJBs altogether in favor of other simpler persistence frameworks such as the JDO or even simple JDBC facades. The authors discuss the pros and cons of entity EJBs and covers most leading alternatives. For those who must use entity EJBs, this book also offers useful advices on a range of topics including how to reduce round trips, shorten primary keys and handle expensive database joins etc.
Part IV covers broader topics including performance tuning, testing, building and packaging. One big problem that even EJB developer can recognize the complex deployment descriptors. One chapter of the book is dedicated to reduce code duplication, automate the deployment process and avoid the "integration hell". The last chapter of the book provides an overview of "what's next" in the EJB space.
Overall, it is an excellent book for all EJB developers and other enterprise developers who want to learn from the successes and failures of EJBs."
Peter Wayner's review:
Although there may be as many 36 plots
in all of literature, the compartively new world of computer books has really had only one: this new technology is simple, very
simple, and it will make your life better and your teeth whiter. Bruce
Tate opened up a second plot in his book Bitter
Java by exploring just how even the best programming ideas have
dark sides. Now he's back with three other authors exploring the world
of Bitter EJB.
This book is more fruit from the same tree. Or, to hack the Java MemeStream even more, more beans for the same mill. If you use Enterprise Java Beans (EJB), or think about using them, you should read
this book to see what can go wrong. The title shows how naming schemes can be misleading because either the authors aren't really
that bitter, or because they're focused entirely on EJBs. This book does not belong in
the same camp
with the Java==SUV crowd. These authors are really admirers who just want to warn people how to avoid problems with Java and EJB.
Tate and his new co-authors, Mike Clark, Bob Lee, and Patrick Linskey are all
consultants who seem to use Java a lot, at least when they're not cheating death. One of the cuter grace notes in the book is a collection of war stories from extreme sports that are mixed in as an allegorical taste of what's to come. Before exploring the problems with a Java concept known as enterprise beans, they tell a kayaking story
that ends with the sentence, "Then we hear a loud crunch and look up to see Eric's stern stationary at the top of the drop, revealing the
sitaution that every kayaker dreads the most -- the vertical pin."
After stories like this, the book goes on to explore just how the
very fancy enterprise beans toolkit can produce an application that moves slower
than a stream filled with honey. Each chapter is filled with antipatterns, or lessons about the software learned the hard way.
They're sort of like points on the map that say, "There be dragons here."
The book is divided into four parts. The first section, termed "The
Basics," explores the simple ways that EJB technology goes bad. The
toolkit was heavily hyped as the perfect solution for building business websites that interface seamlessly with large databases. As the business
grew, new servers could be added without grief. Alas, as this
section points out, there are many reasons why an elephant gun can be
the wrong weapon for getting rid of mice in your house.
The next section on "Networks and Messages" describes how good ideas
can turn into slow code when people misuse the fancy tools for scaling
EJBs. In theory, the EJB toolkit will split up processes simply across
multiple machines to handle more customers, but in practice all of the
communication can slow things down considerably.
The section on "EJB Persistence" describes how the much-hyped system
for seamlessly storing away enterprise beans in databases can weigh
down a system. My only beef is that they left out much information on Prevayler, a much-maligned and
misunderstood ultra-light toolkit that is like an anti-EJB persistence
layer in every possible way. I'm enamored with it, if only because it's
such a radical move away from the monolithic APIs like EJBs. While they
liken using EJBs to snowboarding in fresh powder with a 100lb pack on
your back, Prevayler is sort of like boots-only hiking.
The last section isn't about EJBs per se, but similar toolkits and
projects that often get used with EJB. There are antipatterns to avoid with JUnitPref and Ant, too. Some of these suggestions, like some in the rest of the book, aren't terribly new or brillant, but it can't hurt to get another lecture on the importance of testing your code.
The book shines when it's exploring what goes on behind the slick facade of the API. Sure, the EJB toolkit will dutifully load up data
from any object on any server in your farm, but you better be careful invoking some of these these methods because the network is slow. The
book often points out how invoking that one simple method from the sales literature
can start up dozens of sluggish threads. Peeling away the layers helps
understand and explain why the system fails.
Many of these lessons aren't limited to Java or EJB. I wouldn't be
surprised if the group of authors was busy rewriting the book with examples from .NET. Unfortunately, some programming problems are very
hard, and building a toolkit with a simple API won't make them go away.
In fact, the simple appearance can cause more trouble when the
programmer can't understand what the secret mechanism inside is doing.
Almost all of the problems in this book arise from programmers who
believe the sales literature when it tells them not to pay attention to
what that little bot behind the curtain is doing. If you're working
in the world of EJB consulting on big iron, then you've got no choice
but to start thinking about what's behind that curtain.
You can purchase the Bitter EJB from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page. Peter Wayner is the author of 13 books including Java RAMBO Manifesto and Translucent Databases.
0 of 184 comments (clear)
No comments match the current filter.