Question:
One of EJB's obvious design goals was to provide an environment that
can scale up to meet the demands of enterprise applications. I'm
curious, however, about the other end of the scalability spectrum as
well. I would like to write an application that can scale up to meet
enterprise demands, but can also be easily used by a single individual
working on a non-networked laptop computer. If I build my
application with EJB, will I alienate this user base?
Answer:
You will not necessarily alienate non-networked
individuals by using EJB, but you will have to package the EJB
components and runtime environment for the individual. Therefore,
EJBs that mediate access to multi-gigabyte databases are a no-go. A
quick analogy is the use of CORBA on the desktop in the same role of
COM as is done by the GNOME desktop environment for Linux. Distributed
objects just give you a simpler way of performing interprocess
communication and it's ok for that communication to happen on the same
machine.
However, your caution is well-justified. EJB is designed for
relatively coarse-grained components involved in transaction-oriented
distributed applications. This involves modeling database entities
and business rules as objects. The typical EJB deployment environment
is in three-tier systems. The first tier usually contains a relatively thin
client. The second tier contains EJB components that validate inputs,
enforce business rules, and mediate access to databases. The third
tier contains the actual databases that drive the application. But
three-tier systems need not be deployed across a network. They can be
deployed on a laptop. By doing so, you gain the advantage of not
having to rearchitect your network application for the desktop.
An important thing you lose by using EJB is the ability to
produce a lightweight application for the low-end. The key is to use
the approach where appropriate. It is easy to imagine a sales
database query system implemented with EJB. Salespeople may need to
replicate a subset of the enterprise data to their laptops for use
when they go out in the field. There would be no reason to redesign
the distributed application when it could run unchanged in the single
user environment. However, it would probably impose a larger
footprint than a reimplemented system because of the need to bundle
the EJB server.