Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

Exceptional practices, Part 3

Use message catalogs for easy localization

  • Print
  • Feedback

Page 4 of 4

Resource bundles can also be used for other localizeable resources, such as text used in Swing components like buttons and labels, or even for nontextual resources like audio files or images.

Hidden dividends from message catalogs

Message catalogs not only simplify the localization process, they also greatly simplify the maintenance of a product's multiple localized versions. With each release, localizers need only compare the resource bundle's previous version with the current one to know exactly what incremental localization work is required.

Using message catalogs to store exception message strings offers another hidden benefit. Once you've placed all the exception messages in a message catalog, you now have a comprehensive list of all the exception messages your application might throw. This provides an easy starting point for the documentation writer to use when creating the manual's "Troubleshooting" or "Error Messages" section. Message catalogs also make it easy for documentation writers to track changes in the resource bundles and ensure the documentation stays in sync with the software. And since error messages are arguably more a function of documentation than engineering, using resource bundles renders it more practical for the documentation writers to own the resource bundle source files, which is probably good for everyone involved -- developers and users alike.

Create useful error messages

Maintaining error message strings using message catalogs requires a bit more work up front than the obvious way of building error messages, but it pays off in a number of ways. The ResourceBundle classes in the Java class libraries allow you to easily build message catalogs into your application. Not only does the message catalog technique enforce a clean separation between the UI and the program logic, it also makes it easier to localize the software and maintain localized versions, and to produce documentation that accurately reflects what the program does. As a further bonus, because ResourceBundle classes make it simpler for people other than the developer to be involved in error message creation, they make it more likely that the error messages will be useful to the user.

About the author

Brian Goetz is a professional software developer with more than 15 years of experience. He is a principal consultant at Quiotix, a software development and consulting firm located in Los Altos, Calif.

Read more about Tools & Methods in JavaWorld's Tools & Methods section.

  • Print
  • Feedback

Resources
  • Read more JavaWorld articles by Brian Goetz: