The new Java Development Kit APIs are rich with many
new and enhanced features and functionality. To the average
developer, it can be a daunting task to decide where each API fits
into the grand scheme of a business application--let alone
what each one does. To help you understand
how the APIs might work together, this article tells the story of
a fictional business--Duke's Bakery--and how the owner and
a Java programmer develop a robust, scalable, and
reliable application to run the day-to-day business.
Duke's Bakery is a large, busy, and well-known neighborhood bakery with a loyal following. To continue their personalized service while scaling the business to accommodate the dozens of new customers they get every month, Duke's owner Kate Cookie has hired Java programmer, Madhavi Rao, to help upgrade their operations with a business application. Kate and Madhavi prefer the Java platform because it not only meets Kate's business needs for today, but offers important features she will need as her business grows:
Right now, though, Duke's needs a clean and easy-to-use user interface and back end so the administrative staff (some of whom have limited computer experience) can track ordering, stock, and employee information. Kate and Madhavi will draw on the following JDK 1.2 APIs to design and create the business application:
Swing is ideal for creating the user interface. The components are highly configurable and use images easily. Kate and Madhavi agree to display sales, customer, and vendor information using Swing components such as tables, trees, labels, text fields, and text areas. They also decide to include photographs with the employee information and use images of baked goods in the user interface. For example, the delicious and proprietary cake recipes that have made Duke's so popular over the years can be viewed by choosing a button with a cake on it.
Because Swing components are separate from the data they display, two components can share the same data model. Madhavi decides to display sales data both in a chart (drawn by a custom component that uses Java 2D) and in a table. Putting the sales data in a shared model avoids duplicating data and enables automatic updating of both components when the data changes. Having two views of the sales data can make it easier to understand, helping Kate and her employees discover which bakery goods are the most popular with their customers. Duke's Bakery employees with permanent or temporary disabilities aren't prevented from using the application, thanks to the Swing components' support for accessibility. For example, if an employee's vision is impaired, that employee could use a screen reader. The Swing components automatically provide the information that accessibility tools such as screen readers need.
The Java 2D APIs provide ways to enhance the user interface with color, graphics, and images to make it easy to understand and use. Kate is so excited about the possibilities, she has hired a graphic designer to help leverage the Java 2D functionality because she knows the less time her employees spend learning and using the new system, the happier and more productive they are.
Kate and Madhavi want to use Java 2D to help customers choose a cake's appearance. They decide to include a module in the application that uses a color chooser for selecting icings, and 2D text for demonstrating the appearance of the text on cakes for special occasions like birthdays and anniversaries.
Duke's is working out relationships with some of their suppliers for automated electronic ordering. The JDK 1.2 cryptography API and Java Cryptography Extension (JCE 1.2) by separate download allow Duke's, the suppliers, and their banks to use digital signatures and certificates to authorize and verify large orders with cash transfers in the thousands of dollars.
From Madhavi's point of view as a programmer, the Java platform is ideal. The rich set of Java APIs gives her a lot to work with in designing and writing this application. She will use JDBCTM to access data in their current database. If they change databases or add another database, the existing JDBC code does not need to be changed.
Madhavi will use JavaBeans to build some of the general parts of the application. This way she can reuse the code she writes for Kate in other similar business applications running on the Java platform.
Because of Kate's plans to use online ordering with her vendors, Madhavi must decide whether to use RMI or Java IDL for network communications. Because the vendors are also using the Java platform, she decides to use RMI. Java IDL would let her application use CORBA functionality to access objects written in languages other than the Java programming language (such as C++), but that is not necessary here. RMI is generally easier to use, and Madhavi wants to encourage new vendors to use the Java platform if they want an online purchasing arrangement with Duke's Bakery.
Of course, Madhavi will use Java servlets to implement an online ordering system that customers can use on the premises and eventually from their own computers at home.
Madhavi considers using the Reference Objects API to create soft references to objects that might be left in memory so the garbage collector has the option of reclaiming the memory if need be. This situation could arise when customers choose custom cake decorations online. As they browse through and try the multitude of decorating possibilities, a number of graphical and image objects could be left in memory--especially if the customer or employee does not remember to quit out of this part of the application.
Madhavi also decides to use one of the classes in the collections API to simulate a first in first out (FIFO) queue. This way, the application can manage the floor when customers take a number and wait their turn for service. Madhavi is considering adding a feature where employees in the back of the bakery are notified when more than 5 customers are waiting for service.
Some of the other APIs are not so critical in this application. Kate does not anticipate needing to access information on fields, methods, and constructors in loaded classes (reflection); making native C calls (Java Native Interface); extending the core Java platform (extensions), or playing sound (audio). But when the application is written, she will bundle it and all its related files into a Java ARchive (JAR) file for installation at the site.
Kate is thrilled with her new business application. Not only does it help her handle current business and accommodate growth, but she can maintain the personal touch that made her business a success from the beginning.
Madhavi will use Duke's Bakery as a compelling reference in her efforts to recruit other small business owners to use her expertise to help them convert to the JDK 1.2 platform too.
© 1994-2005 Sun Microsystems, Inc.