Bitter EJB 184
Bitter EJB | |
author | Bruce Tate, Mike Clark, Bob Lee, Patrick Linskey |
pages | 412 |
publisher | Manning |
rating | 9 |
reviewer | Michael Yuan, Peter Wayner |
ISBN | 1930110952 |
summary | Anti-patterns in Enterprise JavaBean development |
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.
EJB is REALLY Bitter (Score:1, Interesting)
Re:EJB is REALLY Bitter (Score:2)
To each their own I suppose.
Re:EJB is REALLY Bitter (Score:2)
Take grep for instance. You can start using grep right away, and do really useful work with it, without even knowing that pipes, awk and sed even exist.
Maybe a dozen shell commands used in a fairly crude way is enough for 99.9% of users to do 99.9% of their work.
The problem with Java in general (not just EJB) is that you really need to gr
Re:EJB is REALLY Bitter (Score:2)
Life is short.
Ironically, Java was created largely to address the "life is too short" problem with C++, largely succesfully (in terms of language design). Nor have I heard many complaints about the lack of generics in Java from practicing Java programmers, as opposed to the numerous armchair quarterbacks who always seem will
Re:EJB is REALLY Bitter (Score:1)
Methinks your knee is jerking.
For my own part, whatever it might have to do with the subject, I prefer a Linux/bash/vim/C/Python programing enviroment and avoid Windows whenever I can.
I had decades of programing experience when I first approached Java, I found it heavy sledding to get going.
I can't imagine how it looks to a programing no
Re:EJB is REALLY Bitter (Score:2)
Yes, I got your argument confused with some parent poster's comment. Sorry.
I had decades of programing experience when I first approached Java, I found it heavy sledding to get going.
All I can say about this is that it's quite likely your earlier experience wasn't heavy C++ development. Compared with that, Java is a breeze.
There are
It's officially: EJB is dying (Score:2)
I expect Java to drop the hype in 3-5 years completely and be where Ada is now.
I expect more hype coming to Python, especially once it gets some EJB-like "Twisted" framework. Or Erlang with its enterprise-quality EJB-like OTP framework.
The time of dot-coms, when C{E|I|O|T}O never pla
Re:It's officially: EJB is dying (Score:2)
I expect more hype coming to Python, especially once it gets some EJB-like "Twisted" framework. Or Erlang with its enterprise-quality EJB-like OTP framework.
I like the twisted [twistedmatrix.com] framework; it's practically another language on top of Python. I've recently discovered another worthy langua
Ada? Cobol! (Score:2)
Re:Ada? Cobol! (Score:2)
Re: UNIX (Score:2)
Re: UNIX (Score:2)
Well, I was speaking as opposed to the forced "innovations" from Redmond that require complete re-learning every 3-5 years or so. It is nice to get things right the first time, occasionally...
Pardon me if I wasn't clear.
(BTW, when we do "think outside the box" and come up with better new ideas, I suspect they'll also have plenty
Re:EJB is REALLY Bitter (Score:2)
The current lack of generics doesn't make Java unusable, but as a "praticing Java developer" I can tell you that Java generics (JSR 14) will sure clean up a lot of ugly code. Sure, th
Re:EJB is REALLY Bitter (Score:3, Insightful)
Unix is complex too. I'm not talking about using the shell or the GNOME desktop. I'm referring to learning how to develop a good application. Learning C well, and learning all the Unix system calls, what they do, proper error handling, and making sure that
Re:EJB is REALLY Bitter (Score:1)
An experienced programmer can pick up Python in a matter of minutes. I have not found this to be true of Java.
KFG
Re:EJB is REALLY Bitter (Score:2)
I have, however, observed over the years that the biggest hurdle for people to overcome when learning Java is to understand how to write object oriented code, and use it to your advantage.
How long did it take for you to learn Java?
Re:EJB is REALLY Bitter (Score:2)
I don't know Python. I have quickly browsed some tutorals, which is enough to understand something about the language. Personally I just couldn't stand the syntax (the same reason I turned my back on Ruby too).
I would assume that you learned Java before learning Python? If this is the case, then y
Re:EJB is REALLY Bitter (Score:2)
Oh, nonsense.
The only thing different over a gcc or g++ compile is telling it which class's "main" you want to use.
Okay, granted, that's generating native code and not using javac
Re:EJB is REALLY Bitter (Score:1)
I would posit that it's easier to understand this bit of code than then the one you submited.
Sure, you and I understand your code, because we grok the whole.
The opinion of an expert is often worthless when considering the opinion of a novice.
As for the MFC I've had a look at it and I don't even understand the mindset that produced it in the first place.
KFG
Oh, please... (Score:2)
Placing the hello world code in a main statement specifies a distinct context in which that code is to be used. It could just as easily be as simple as:
System.out.println("hello world");
Now, before you start clacking away at your keyboard, saying that al
Re:EJB is REALLY Bitter (Score:2)
I'll grant that for small projects, a language like Perl or Python can take less code and be superficially easier to understand that the equivalent Java. Right tool for the job, and all that.
The original poster's point, though, was that you had to understand all of Java before you could understand "Hello World", which is obviously not true.
At the other end of the scale, however, if I had a multi-hundred thousand lines of code, 30 programm
Re:EJB is REALLY Bitter (Score:2, Insightful)
Well, I learned how to cope with UNIX with the following steps:
Re:EJB is REALLY Bitter (Score:2)
Why are you obliged to learn again? you didn't your homework in the first place?
Thanks to Free (Speech) Software like GNU/Linux distributions, or *BSDs, you may learn Unix as an hobby... fire up slackware, tune it and then play Wolfenstein
False! after you tune your slackware yo
Re:EJB is REALLY Bitter (Score:2)
I agree it can seem this way at first -- especially if you don't have previous exposure to some of associated technologies or you're trying to understand the concept in a vacuum without some concrete examples to work on.
I found "The J2EE Tutorial" (Bodoff et al, published by Adison Wesley but the content is also available on the web from Sun) very helpful by working through the simple examples.
Sure, it's still big, but you're not expected to remember all the details any more than
Re:EJB is REALLY Bitter (Score:3, Informative)
First, let me see if I understand your criticism correctly. Distributed architecture is a very complex and advanced form of software architecture. There is not merely one simple solution for all requirements, but an entire host of options to ensure that the right system is built to solve the problem at hand. This might include distributed components (EJB), but might also include CGI-based services (Java Servlets), asynchronous mes
Re:EJB is REALLY Bitter (Score:4, Insightful)
And a completely different set of deployment descriptors for every single EJB container, meaning you can't take your EAR file developed for (say) JBoss and deploy it on WebSphere or BEA. That, to me, is one of the biggest problems with EJB--zero portability of the finished packaged code. Wasn't Java supposed to be 'write once run anywhere'?
Deployment Descriptor Portability (Score:2)
In EJB 1.0, there was no portability to speak of, as the descriptors were compiled classes. EJB 1.1 introduced a standardized XML
Re:EJB is REALLY Bitter (Score:2)
LOL! Look at the last fifteen years of Microsoft API history and make this statement again!
Microsoft offers only the illusion of simplicity through their mind-altering marketing campaigns. Their reality is very much the opposite, where unchecked complexity and no real ways to troubleshoot problems are the main attributes of their software.
Re:EJB is REALLY Bitter (Score:2)
I think that both of the Bitter Books are excellent resources and I would highly recommend them to anyone serious about Java development. Many of the lessons in both books transcend Java and are applicable to other languages as well.
All in all, a fantasic effort.
Where's the review? (Score:1, Insightful)
Languages need novices, novices need good books. (Score:5, Interesting)
At least the novice developers can use it. Look at Visual Basic: VB is the most popular language with over 3 million developers simple because anyon can pick it up and get started, this leads to more developers, which leads to more apps, which helps Windows dominate the desktop.
Now a large number of those first projects are garbage apps, but at least they give a starting point. We need languages that novices can jump into, then good books that can help steer them as they continue learning the language.
Re:Languages need novices, novices need good books (Score:2)
I find it funny to see your domain address.
j/k
Re:Languages need novices, novices need good books (Score:1)
Well, what can I say, I have a niche to fill.
Re:Languages need novices, novices need good books (Score:4, Insightful)
I'm hardly either command line nor dense mathmatical code shy.
Today I'm a bit of a C+Python snob, but I went through a VB phase when making the switch to graphical shell programing. It was like magic. It got me up on my feet and running, producing really usable apps in the Windows enviroment in no time flat.
I "outgrew" it in fairly short order, but as a stepping stone between "old world" and "new world" I found it invaluable.
KFG
Re:Languages need novices, novices need good books (Score:2)
It took awhile to realize (after coding 25% of an app) that the computation model of VB was anti-OOPs.
With the objects being forms. With data objects public and the associated fuctions private. That is the fields of a frame were public but the methods of those fields were private and not triggerable from outside pushing the buttons.
So to make thing
Re:Languages need novices, novices need good books (Score:3, Interesting)
Of course, one could also argue that folks would be a lot better off starting with Assembler, moving to C, and then to Java. Especially with Assembler, at least *then* they would have an understanding of what actually goes into an I/O instruction as trivial as "p
Re:Languages need novices, novices need good books (Score:2)
But, it there is a cost for device independence. A small cost I think, compared to say C++. Talk about needing to understand the world to get anything more than Hello World done in that envrionment.
The compromise of Strong Typing vs Pure OOPS I think was well done in Java. So you pay for that too.
I teach on the side and the hardest thing I find for the students is the requirement (not mine) to use C++. Java would make their l
Re:Languages need novices, novices need good books (Score:3, Insightful)
The biggest problem facing EJB and all of the major environments right now is not how easy it is to work in an environment, but how well the developer understands distributed components and n-tier architectures. Look at SOAP, I've worked on a couple of projects that involved SOAP, the most recent is a
Re:Languages need novices, novices need good books (Score:2)
Re:Languages need novices, novices need good books (Score:4, Insightful)
At least the novice developers can use it. Look at Visual Basic ... anyon[e] can pick it up and get started ... Now a large number of those first projects are garbage apps, but at least they give a starting point.
The idea of a novice picking up J2EE is fscking hilarious. J2EE is a framework for Enterprise applications. Almost by definition, these apps are outside the purview of a novice, at least without careful hand-holding by a guru.
Novices - using any language or environment - don't write applications with scalable components, a robust transactional system, a complex persistence mechanism, a high quality messge substrate, and a directory system.
One might as well complain that an F-15C air superiority fighter is inferior to a Cessna 172 because a beginner can fly a Cessna with very little training. If one needs to shoot down a Mig-29, the Cessna is not going to cut it. J2EE developers need to come to the environment after deveoping a sound foundation in other technologies, up to and including RMI and CORBA.
Brief? (Score:2, Insightful)
A quick overview of what is contained in the book is informative, but not necessarily insightful.
Gotta point that out; sorry for nitpicking, but I like book reviews to tell me not only what's in the book, but how good the book is.
Astroturfing EJB (Score:1, Insightful)
Principals of Slashdot and OSDN may have investments in the stocks of the companies discussed on this site and will disclose any interest if they are posting a story about those companies or their products. Contributors to this site may or may not have an interest in a company or product they are discussing. The decision to disclose that information is theirs to make. We do not guarantee the veracity, reliability or completeness of an
mtowtdi (Score:5, Funny)
almost everything can be done in several different ways
I guess imitation is the finest form of flattery but I think they might be violating perl's IP here.
Sounds Helpful (Score:3, Informative)
I'm also glad the book talks about the failed TSS PetStore performance shootout, although I'm curious about how it's presented. Suffice it to say that PetStore really isn't (or at least wasn't then) a good example of the way to do things.
And for those complaining about the difficulty of EJBs, many AppServer vendors provide development tools that make coding EJBs very easy. Although, these tools tend to be really pricey.
Worth Learning? (Score:5, Insightful)
The vast majority of people who I have talked to seem to indicate that they have never come across any project under development where using EJB wouldn't be complete overkill, and that much simpler, easier to maintain, and cheaper solutions seem to be the path chosen.
These aren't all small projects either, I would venture to say all of the people I have spoken with (or projects I have been working on) have been in the $50,000 - $2,000,000 range, and none of the senior developers or architects on these projects have ever dreamed of going anywhere near EJB.
Thoughts?
Re:Worth Learning? (Score:2)
EJBs, and Java in general, are almost always entirely the WRONG approach to producing websites.
To make an efficient site, use a scripting language like Perl [or OCaml, but I declare an interest in that], write CGIs, use mod_perl to make it run efficiently, and where you want to optimise, put your logic into stored procedures. Templating and SSIs are also useful.
Rich.
Re:Worth Learning? (Score:2)
Re:Worth Learning? (Score:3, Insightful)
EJBs usually, java, no. The servlet architecture is one of the best things to happen to web development as far as making highly scalable web applications.
To make an efficient site, use a scripting language like Perl [or OCaml, but I declare an interest in that], write CGIs, use mod_perl to make it run efficiently, and where you want to optimise, put your logic into stored procedures. Templating and SSIs are a
Re:Worth Learning? (Score:2)
Firstly I've written mod_caml [merjis.com] which is, you'll be disappointed to know, an interface to the Apache API from Caml.
Secondly, OCaml isn't just a compiled language.
Thirdly, if you'd e
Re:Worth Learning? (Score:3, Insightful)
I'm a little confused by the point of this statement. Why am I disappointed to know this?
Secondly, OCaml isn't just a compiled language.
Well, no, it's got a repl, but that would seem to defeat the purpose of the static typing.
Thirdly, if you'd ever written a website you'd know that queries on the database dominate. Interpreted, compiled - it makes no difference.
You left out the word ``
Re:Worth Learning? (Score:2)
(Obviously? Surely no one in 2003 would be advocating forking and connecting to the database?)
Rich.
Re:Worth Learning? (Score:2)
(Obviously? Surely no one in 2003 would be advocating forking and connecting to the database?)
Well, that's pretty much what CGI means. The CGI specification includes details like commandlines, environment variables, stdin, stdout, etc...
When I say a well-written CGI will be slower than a well-written servlet, I'm referring to a CGI as defined in the cgi specification. mod_perl is not used for writing CGIs, it's used for mak
Re:Worth Learning? (Score:2)
Re:Worth Learning? (Score:2)
Evidently nothing, since Perl has plenty of very good templating libraries.
Rich.
Re:Worth Learning? (Score:5, Interesting)
Namely, whenever people on Slashdot complain about how EJBs are insanely slow and seem to cause more problems than they solve, someone always posts something along the lines of "they weren't used properly." Which is nice and all, but I have yet to figure out what is a proper use of EJBs. So, that's my main question - what should EJBs be used for? When are they the right tool for the job?
I wasn't able to figure this out the last time I worked with a J2EE environment. All in all, it seemed that they were too complicated for what we were doing. And I wasn't able to see a problem where they would have been a good solution.
Of course, I've been soured to them (or bittered, maybe?) based on the project which was basically people questioning the contractors' choice of CORBA on their Java-based system. Someone suggested to management that the contractors should have used EJBs and that this would have made the finished project "Better." So I got stuck with the task of trying to demo a system with CORBA replaced with EJBs instead - never mind the fact that most J2EE environments use CORBA as the RMI layer between beans...
So to sum up: What is the "right way" to use EJBs? And what types of problems are they best at solving?
Re:Worth Learning? (Score:5, Insightful)
The first thing you should think about is pre-J2EE history. Back before J2EE everyone was developing their own systems. They had their own persistance layer, their own distributed transaction system, their own network protocols in some situations. Was this system faster? Yes, of course it was. If you can develop your own system custom to your task, it's always going to be faster.
Performance was not the reason for J2EE. Scalability was not the reason for J2EE. They are part of a new push in the software world. Overall economics is where J2EE comes in. It's more expensive to create your own framework than to buy one. It's more expensive to train developers on how to use your framework than an existing standard. If you had one person developing just your infrastructure full time it would cost you 100K/y in salary, which is more expensive than the most expensive J2EE server will run you on average.
Now I would like you to think, "Why don't we write our own database systems?" If we write our own system we wouldn't need to parse SQL. We could store the data in relation formats where it's good, and hierachial where it makes more sense to be hierarchial. The system would be faster be a very significant amount.
The point is if you keep "reinventing the wheel" (I hate that phrase.) your competitors will beat you to market.
I think I've covered two of the main points here.
1) It can be cheaper
2) It can be quicker to market.
Who cares if it requires a cluster of Opterons to run, software has always cost more than mass produced silicon waffers.
So, back to the main answer, which by now you probably can see, when to use EJB.
1) If you need distributed transactions.
2) If you need platform independance. (.Net clause)
3) If it will let you get to market quicker.
4) If you need declaritive security checks.
If none of those ifs apply to your project, then you would be an idiot riding hype if you use EJB. As for my EJB projects, I can generally say I need all 4. You can't force Linux on clients because they don't have administrative people that will patch it like they do windows. You can't use windows because it isn't reliable as a server generally. Let them pick and live with their own decision is my philosophy.
Re:Worth Learning? (Score:1, Insightful)
The biggest problem with EJBs is poor developer understanding of how to use them. Not just technical nuts and bolts, but problems such as innapropriate long-term use of Stateful Session Beans a
I had a great experience with them (Score:1, Interesting)
EJB's depend a lot on the tools as well I personally think WebSphere sucks, it looks good but it was ju
Re:Worth Learning? (Score:5, Informative)
With modest hardware we're competing quite effectively with the mainframe app we're replacing.
Our worst choice was to use a Swing front-end instead of Struts.
My advice for anyone getting into ejb development is DESIGN. DESIGN. DESIGN. Know exactly what you're trying to do. Prototype a lot. Test all the time. And get a quality dba, because the effect of solid db tuning will usually beat anything you can do at the app server level.
Re:Worth Learning? (Score:2)
The main mistake of EJB. (Score:5, Interesting)
A system with complex rules isn't necessarily more powerful, but it's usually more difficult and error prone.
Unfortunately this misconception is very common in computer science. People tend always to create complex APIs/infaces and protocols just to get a "powerful tools". The result is the security and error ridden state of the internet and computers we see these days.
Strangely other hard sciences have seen these problems decades ago (sometimes even centuries ago) and changed their terminology and fundations accordingly. Take e.g. Mathematics with is based on 2nd order logic and set theory. And this started with Godel, Riemann, Abel and Gauss about 120 years ago. We have the same drive now in Physics with Wolfram and co. propagating simple cellular automata. Some people in string theory move in this direction, too.
Unfortunately computer scientists seem to be immune to this amount of common sense right now. Perhaps they need some centuries of fumbling aroung with overly complex model, too, until they get back to earth.
Re:The main mistake of EJB. (Score:5, Insightful)
I wouldn't put it that way. It may be that Einstein's dictum of "make it as simple as possible, but no simpler" wasn't followed. That I'd accept as a valid criticism of some of Java and it's libraries.
A system with complex rules isn't necessarily more powerful, but it's usually more difficult and error prone.
I'm not sure what you mean by "with complex rules". The essence of the matter is that developers want to use complex libraries and subsystems, in the hope that they'll solve equally (or more) complex problems. EJB's (and J2EE's) success or failure should be judged in that light. This is also true with regard to your "error prone" comment. The exact attraction of the J2EE architecture is that it should remove both risk and fragility from the system by using robust, tested code. There is a very large test suite that must be passed in order for an application server to be J2EE compliant. I think very few that have deployed J2EE applications would characterize the environment as "fragile".
It certainly seems to have solved some need, because many projects are using it, many successfully. It certainly runs on the highest-end server hardware out there (up to over 100 processors in a single SMP box, which can be clustered).
Unfortunately this misconception is very common in computer science. People tend always to create complex APIs/infaces and protocols just to get a "powerful tools". The result is the security and error ridden state of the internet and computers we see these days.
First of all, J2EE systems haven't been the victim of many security exploits that I've heard of...Microsoft systems seem to be the usual victims. Both Unix and Java are Internet-hardened technologies that have stood up very well in real world use. Let's hear your alternatives now...
Re:The main mistake of EJB. (Score:2)
I've seen one J2EE implementation that doesn't fail gracefully, however, and doesn't provide useful feedback to the hopeful and rather under-qualified developers. The biggest fault I assign to these developers is using a commercial J2EE implementation complete with EJBs for a project that has only a few dozen tables and barely any data. They really could have gotten by with Perl scripts for this projec
Re:The main mistake of EJB. (Score:2)
Incidental success... (Score:5, Interesting)
For example, most GUI toolkits. Usually, you follow the examples and tutorials as a model, you read through the API docs, and you can build a system that works pretty well. Even many other kinds of enterprise software infrastructure - take TIB Rendezvous, or similar messaging systems - I've written apps with many of them that scale, are efficient and work well on the first try.
I've seen several EJB apps written, and worked on a few myself, and you can read all the damned API docs, follow Sun's examples, read your app server documentation, and so on, and still, you just shoot yourself in the foot. This isn't the first book on patterns and anti-patterns of EJB usage, it's the umpteenth. Why? Because the EJB model was so poorly thought out prior to its implementation that if you follow the specs and build the kind of system they _seem_ to want you to build, it just doesn't work.
Instead you need to have built 10 systems that don't work before you have a clue how to make one that doesn't. Frankly, it seems to me like more trouble than it's worth for what you get (which is basically transaction-aware objects, at least based on my knowledge from the EJB 1.1 era). If you just use session beans, if you don't use entity beans, if you don't do distributed transactions, if you don't use stateful session beans... then you can build an app that works.
Great. I think the J2EE APIs have a lot of great, great stuff in them, but EJB just tweaks me out. Why the hell didn't somebody try using this hunk-a-junk before they released their 1.0 spec, or maybe their 1.1 spec, or howzabout the 2.0 spec? Maybe things are better these days, but if your API looks like it's supposed to provide a pattern for enterprise database applications, shouldn't it actually do that, or somehow redefine what the hell it's really supposed to be for?
Re:Incidental success... (Score:2)
I think EJB is one domain, whose programmers really would benefit from some kind of formal training on the architecture. This could be a few weeks at a reputable training class or a good apprenticeship program within companies. Enterprise apps aren't exactly something that can be pick
Re:Incidental success... (Score:2)
You could ask that about a lot of Java APIs. I mean, they can't even get the basic collection classes right.
Does it tell you when NOT to use EJB? (Score:5, Insightful)
The infrastructure for those systems are hard to write. The whole point of EJB is to have as much underlying general purpose infrastructure as possible already written for you, so you can plug your ad-hoc business logic on top. This puts development of these systems in the reach of a greater number of developers. But if you can write it yourself, you'll be better off. You'll be in control of more of the code, and won't spend your time messing with tuning parameters and configuration files for someone else's code. One exception is a distributed transactional system where it simply gets to be too much for you to reach your deadline. The other is a system that might be integrated into a larger system like that, that is already based on EJB. (Or the customer might be requesting EJB, maybe for a good reason.)
I sat in on an interview once where we were explaining the architecture of a server product we sell, and the first thing out of the interviewee's mouth was "You don't use EJB? Oh I'm surprised- you should really be using EJB!" That killed the interview right there.
Re:Does it tell you when NOT to use EJB? (Score:3, Informative)
Re:Does it tell you when NOT to use EJB? (Score:2)
Yes, too many people see J2EE as synonymous with EJB and vice versa. Of course, that's where the bulk of Sun and nearly everbody else's focus is, but strictly speaking just doing JSP and servlets with Tomcat is also J2EE.
(And of course for small, non-critical systems you might well be better off going with something lighter weight like PHP.)
Bitter is right! (Score:2, Insightful)
Whatever happened to making frameworks that do one thing only and do it well?
Reminds me of a comic's joke... (Score:2)
Bitter.
Is EJB dying? (Score:5, Informative)
That's how every good slashdot troll should begin. But if there is one technology that is currently at real risk of extinction in the Java world it is EJB. Almost every new J2EE project that I hear about steers clear from EJB towards simpler solutions such as plain servlet/jsp with JDO for persistence. Then you scale it horizontally through mod_jk or a hardware load balancer. No need for confusing (and restrictive) enterprise beans.
Entity EJBs have been critisized many times and rigtfully so. Session beans I find are OK but for me (and my company) it's a case of "I really don't need them given the baggage of complexity and the restrictive nature of their API.
Message driven beans are probably worthy of consideration but there isn't that much to them really. Certainly not something you couldn't implement on your own with plain JMS. I've done it, didn't take much time and it worked just as well as the specc'ed MDBs. And I don't have to run within an EJB container. I can deploy to Tomcat and have SonicMQ running remotely.
Is EJB going to really take off? Seems that the spec was vastly improved but not all problems with the technology have been addressed and then there is the phsycological issue for many developers who had nasty experiences with EJB 1.1 development.
I won't trash EJB they are a certain way to develop enterprise applications. I just find that I end up with much simpler design if I avoid them in lieu of something simpler. My preferred stack at the moment (assuming no legacy systems to integrate with) is as follows:
Re:Is EJB dying? (Score:3, Informative)
If I were starting a new project this is what I would use. Hopefully this would give some of you
+ Eclipse (IDE)
+ Hibernate (JDO like Persistence)
+ Jetty (or Tomcat).
+ Spring Frame Work (struts is out).
+ Oracle (or your favorite open source DB).
Re:Is EJB dying? (Score:2)
Struts? (Score:2)
Re:Struts? (Score:2)
Re:Struts? (Score:2)
Re:Is EJB dying? (Score:2)
Re:Is EJB dying? (Score:2)
Consider the problem of automating around manual processes, not just "old mainframes."
Re:Is EJB dying? (Score:2)
Yeah, it's not that bad once everyone understands
which components are stateless and which are persistent and why. Then you just set everything up so the various flags and triggers are correct, and so there are no bypasses in the process.
Story probably should have provided a link (Score:4, Informative)
Bitter Java went in exquisite detail into the various ways things can go wrong in Java development, and in Java-like languages, in an attempt to teach good design by counterexample (most of the book concerned real-life examples of what they called "antipatterns"). It is one of the better books on OO design I've come across. Unfortunately I accidentally left my copy on an airplane somewhere between Indianapolis and Dallas
Good database design is still essential (Score:5, Interesting)
Every failed EJB based system (and many failed non-EJB systems) that I've seen had poor database schema design at their heart. In almost every case, engineers familiar with OO design, didn't really bother to learn anything about RDBMS, perhaps because they felt them to be old-fashioned, and tried to ignore the database as much as possible, and put too much logic outside of the database.
There's a lot to EJBs, sure. But you first have to learn the basics of good database design, for without that, you are hosed.
EJB provikes bad database design (Score:3, Interesting)
You see it in the idea of entity beans that encapsulate data, and the higher layer of session beans that encapsulate process (i.e. business logic). It encourages you to not use RDBMS business logic (such as constraints, triggers and a sound datamodel).
Lighter approaches such as the simpler "model-2" servlets, using plain JavaBeans as data access layer much more leads you to put
Re:EJB provikes bad database design (Score:2)
I think the parent is trying to say that very major problems can come from this view point no matter how good you are at EJB or Java programming.
>It encourages you to not use RDBMS business logic (such as constraints, triggers and a sound datamodel).
I never really understood this point. In any serious major project I've worked on, there is alway some secondary way to
Re:Good database design is still essential (Score:3, Insightful)
Agreed. It is also easy to argue that doing the database design first in a project rather than slapping it together as classes are created is the best approach. Normalization is important, too. I've seen a database where some tables had over fifty columns, where there were blatant opportunities to split the tables up into much more logical entities. But the developers didn't do it, and the software suffers
Re:Good database design is still essential (Score:2)
Re:Good database design is still essential (Score:2)
Same problem. No matter what the marketing will tell you, without a solid database design under the hood, you are hosed.
Re:Good database design is still essential (Score:2)
I totally, 100% agree with your view point about good db.
J2SE vs J2EE (Score:2, Insightful)
Prevayler solves a very specific kind of problem. (Score:5, Insightful)
Without a more effective query semantic, prevalence will be limited to a very small subset of the problem space currently solved with O/R solutions.
The knowledge gap appears to be in the analysis of the value of SQL queries in programming and computational problem solving. My assertion: relational programming is actually different from object oriented programming and is more useful than OO for a number of problem types, including asking ad-hoc questions of the data set (very common for reporting, etc.).
This feeling, that SQL and RDBMS's are somehow a "throwback" or an "obsolete" technology reveals a lack of understanding of the relational programming model. This feeling has also led to a lot of "trips around the block" (Yet another OO database, etc.). OO databases don't really catch on for anything because they don't solve real world problems better than relational DB's. Yet time and time again, OO databases are trotted out as the "road to freedom from SQL". SQL, appropriately applied, isn't any more confining than Java or any other programming language, appropriately applied. Unless you take a close look at one of the problems that SQL solves elegantly, however, this statement will not make any sense to you.
Based on my experience, the biggest differences between the OO model and the Relational model include:
Basically, I accept the prevaylance performance numbers, simply because I can make any decent RDBMS perform queries 3000x to 9000x slower than nominal on a sufficiently large dataset by screwing around with the indices. What I don't accept is the claimed significance of your numbers. Who cares if your system is 9000x faster than Oracle + O/R for your carefully chosen example problem if my real world problem is 5x faster but requires 100% more java code and can't easily handle new report types? Most of the time, performance is one of the last aspects of a new system to get any attention, and IMHO, that's exactly the right emphasis for performance in system development.
Let's propose a real business application with dozens of objects in a complex model and then throw a few million instances at it. Now let's start adding queries to the system and let's see who does better? I'll bet that I don't have to try very hard to get the queries 1) written faster and 2) executing faster against the O/R layer than you do against the objects in RAM, but then since I'm choosing the dataset, you know that's not going to be too difficult :)
I'll freely admit that you guys have some really cool ideas, and I *really* like the idea for small apps that already use files for persistent state. Only problem is that none of the products I've worked on in the last ten years fit a mold that prevalence would make easier. If anything, your approach mak
Agree with your assesment of SQL (Score:2)
Instead almost every O/R layer under the sun assumes that I just want to store objects in the DB. Almost never in several years have I in fact wanted to do that, usually I wanted the results of a good query to be represented for me somehow. I think this can be done in Java (after writing three O/R
Thoughts about j2ee (Score:3, Interesting)
I've been doing J2ee development for the last couple of years and on the whole I don't think EJBs give you many advantages but they do add a lot of confusion.
The main problem is that it isn't clear the best way to use them, there are so many techniques and patterns out there but there is nothing you can point at that is the 'best practice' - it all depends on your application.
The advantages of easily scalability of business objects over multiple servers is useful, but since the database is the main bottleneck in most enterprise applications the scalability of the business logic layer doesn't give you a lot. Also many applications require communication between the various clients (through the server) but since EJBs are designed to be location independent, there is no nice ways of communicating between session EJBs on various machines. It is possible to do it with message EJBs but it's not easy. Another thing to note is that you don't need EJBs to separate the business layer from the presentation layer, it's easy to do with normal classes. You also don't need EJBs to have the business logic running on another server - you can just use RMI.
The automatic EJB transaction management is useful but since it relies on exceptions being thrown and it can get very confusing, and often isn't flexible enough - we seem to resort a lot of the time to UserTransactions.
On top of that a complex database schema seems also impossible to map to Entity EJBs in a useful way. We have 300+ tables and the presentation layer needs all sorts of combinations of relations between the data that mapping the data into 'Entities' just seem to make data access inefficient.
Why EJB is chosen (Score:3, Insightful)
Programmers are seduced by the buzzwords, and want to be able to put EJB on their resume, so they will either actively encourage their management to choose EJB, or will use it for every imaginable task if it has already been chosen.
In reality, over 95% of EJB applications could have been developed cheaper and faster and with less bugs if they used Java without EJB. You can get scalability, clustering, and failover with servlets, without the tedium of EJB. You can get persistence with JDO or JDBC facades, with better performance and simpler than entity beans. You can get asynchronous messaging by using JMS without EJB. You can get remoteness using RMI without EJB.
But the reality doesn't matter. Both programmers and managers have been seduced by the hype and buzzwords, so EJB will live on even if it makes things ten times more difficult and expensive.
Re:does the book address (Score:1)
Re:$4.50 cheaper and free shipping (Score:3, Informative)
Direct link to the book on Amazon [amazon.com] without stealth referral info!
Re:$4.50 cheaper and free shipping (Score:1)
Re:Java pros and cons (Score:1)
"Besides, use
Oh sure, and when M$ decides that they need to sell yet another language you can write, whatever, again in WinFX. Maybe all those VB programmers that were layed off because of
Re:EJB For Scientific Computing (Score:2)
No. Scientists are too smart to be fooled by the buzzwords and hype that cause managers and programmers to choose EJB.
Re:EJB For Scientific Computing (Score:2)
Let's see: roughly speaking, an EJB container provides three services: transaction management, remote calls and security.
For scientific computing, you don't want the security layer: it will just slow you down.
You also don't need the transaction management: you perform a calculation, and you store the result. Why would you want a rollback for that?
Remote calls might seem interesting at first (think clusters), until you realise that EJB has no support for parallel tasks. (Except for message driven beans