Frameworks save the day
Use an extensible, vendor-independent framework to accomplish the top tasks in server-side development
By Humphrey Sheil, JavaWorld.com, 09/29/00
In server-side development, a number of core tasks crop up over and over again. Most developers know that such tasks can and
should be pulled into a core framework, built and tested once, and reused across multiple projects. However, knowing something
and doing it are two different things.
The framework concept has been kicking around in software development for a long time in one form or another. In its simplest
form, a framework is simply a body of tried and tested code that is reused in multiple software development projects. Smart
companies invest formally in frameworks and good developers build up a library of components that they use often. Such actions
reduce development time while improving delivered software quality -- which means that developers can spend more time concentrating
on the business-specific problem at hand rather than on the plumbing code behind it. A good framework also enhances the maintainability
of software through API consistency, comprehensive documentation, and thorough testing.
At one level, the framework showcased in this article does the simple things you need every day: logging, exception handling,
JNDI lookup, configuration, and database management. Delving deeper into the design and implementation however, you will see
that the framework also provides application server independence, future hooks for adding management services, and a well-defined
extension mechanism.
Note: To download the framework's complete source code in zip format, go to the Resources section below.
Goals for the framework
Before setting out to build the framework, it's worthwhile to set out some basic objectives against which we can measure success:
- The framework should be simple. The number of objects should be minimal, with simple methods and shallow inheritance hierarchies. Furthermore, the API must
be consistent across different framework modules to minimize the ramp-up time required to start effectively using the framework.
- A developer should be able to add new services to the framework easily. You can be sure that your framework will grow over time, becoming a balkanized hodge-podge reflecting the designers' and
developers' personal coding styles. If from the start you lay down a well-defined extension mechanism that is powerful enough
to meet the needs of your framework providers, you've laid a sound base on which to build and extend the framework over time.
- The framework should have solid documentation. This may sound obvious, but it rarely happens in practice. At the very least, users will expect a good level of javadoc commenting
and an overall block diagram outlining the major components in the system, along with sample code showing how the components
can be used.
- The framework should be usable from any J2EE component. This includes EJBs, servlets, JMS listeners, and regular Java classes. Accomplishing this is not difficult, but it needs
to be kept in mind during development.
- Developers should be able to deploy the framework to multiple application servers. A really useful framework will offer developers the same level of functionality no matter what application server they work
on. For example, if a vendor claims that its environment is EJB 1.1 compliant, then I expect certain things to be present
in that environment. In the same way, if a framework is available on application server X, then it should be fully functional
on that server, no ifs or buts. Above all, this complexity should be hidden from the end user wherever possible.
Framework assumptions
In order to make our framework easier to maintain, some assumptions are made: