Mini-antipattern: Everything Is an EJB
After interviewing five consultants and programmers for this topic, I discov-
ered that the one common antipattern was the application of EJB s to trivial
problems. This antipattern is a more direct example of the Golden Hammer
antipattern. Each consultant had an example of bright programmers using this
advanced technology to build simple applications. One gave an example of a
three-tier EJB application built to display a few time sheets. Another had a
team who used EJB s to build read-only reports that used a single database
table. Many saw customers replace working, robust applications built on solid,
well-suited technologies simply to stay current (a nebulous benefit under the
best of circumstances). EJB s can help save us from complex details of persis-
tence, transaction integrity, security, and distribution—at a price. If our appli-
cation doesn't need the capability, our costs will quickly outpace our benefits.
An application should have many of these characteristics to be considered an
Complexity . If the problem is not complex, the effort and overhead
should steer us toward a simpler architecture.
Persistence . Sometimes, a persistence framework can simplify an applica-
tion significantly. Still, other persistence solutions, such as databases or
even files, may be more appropriate for simpler solutions.
Stringent transactional integrity requirements . Building robust transac-
tional applications takes effort, especially for persistent distributed appli-
Distributed or multitiered deployment requirements . Stand-alone applica-
tions usually won't have the complexity or sophistication to mandate
A complex, shared object model . At a cost, EJB s provide the ability of lay-
ering an understandable object model over legacy systems and sharing
that model across many users.
When few of these conditions are present, it is unlikely that EJB s will provide
enough benefit to outweigh the performance and development costs. I am
confident that many programmers will continue to use them anyway.