Java tip: Orthogonality by example
Orthogonality is a concept often used to describe modular and maintainable software, but it's also a design principle found
(and broken) in some of our most popular Java utilities. With this short article you'll wrap your head around orthogonality
once and for all -- by seeing how it is implemented, and violated, in Log4j. Workarounds are also discussed.
Jens Dietrich,
May 2013
Java Fun and Games: Explore the geometry of nature
Enhance your Java games with math-based fractals that imitate nature's geometry.
Jeff Friesen,
June 2007
Some Recipes to Improve Your Google Web Toolkit Development
The Google Web Toolkit (GWT) is an open source toolkit that allows you to create AJAX-based Web applications that are completely
written in Java. This article summarizes experiences gained when implementing a client/server Web application with GWT and
Tomcat. Lessons learned are shared as tips and recipes that can improve the development of your GWT-based Web applications.
Klaus P. Berg,
April 2007
The Java Enclosing Class as an Implementation of the Builder Pattern
In the traditional Builder Pattern, a Product's encapsulation can be compromised since its compositional logic resides in
another class. What if you could determine a Product's composition at run time without breaking encapsulation? In some cases,
you can accomplish this with one of Java's more obscure features: nested classes.
Jason DeMorrow,
April 2007
Java Tip 143: Utilize the Database Schema Browser
The Database Schema Browser utility eases the task of database
lookup by providing users with a consolidated list of tables and
their definitions with one simple hit to the servlet. What's more,
you can use the browser's print options to print out a handy
database reference. This tip highlights how you can use Java
Database Connectivity (JDBC) APIs to create a simple database
utility. It's a first step towards building more complex utilities
like code generators and SQL browsers.
Saurabh Singh,
October 2003
Java Tip 142: Pushing JButtonGroup
Swing's ButtonGroup class allows radio button grouping
to ensure single selection; however, the implementation raises many
question marks. You cannot retrieve a reference to the currently
selected button in the group, and the class lets you select or
deselect any button accessible through a reference, not
just those belonging to the group. This tip describes how
JButtonGroup subclasses ButtonGroup to
offer a more solid implementation, while providing convenience
methods that make JButtonGroup much simpler to use.
Daniel Tofan,
September 2003
Java Tip 141: Fast math with JNI
Java 2 Platform, Standard Edition (J2SE) 1.4x uses a new
StrictMath package to perform mathematical
calculations, but many of these math routines are much slower than
the corresponding routines in J2SE 1.3. Luckily, Java Native
Interface (JNI) enables you to circumvent this serious performance
bottleneck.
Jeff S. Smith,
August 2003
Java Tip 140: Automatically generate JavaBeans from XSL files in J2EE applications
One way to write Java 2 Platform, Enterprise Edition (J2EE)
applications that produce dynamic content is to use servlets,
JavaBeans, XML, HTML, and XSLT (Extensible Stylesheet Language
Transformations). In this tip, Klaus Berg looks closely at the
automated conversion of HTML form parameter names to JavaBeans.
Form parameters are a part of HTML embedded in an XSL file. The
generated beans serve as intermediate storage in J2EE applications
and hold user-entered data in an HTML input form. Typically, the
beans convert into an XML tree that provides the input for an XSL
transformation that finally produces the HTML output for the user.
Klaus P. Berg,
July 2003
Java Tip 139: Ask the right questions in your survey application
Businesses often use surveys for market research, user feedback,
and various evaluation methods. Increasingly, surveys are being
placed online, and good software is needed to make them more
efficient and cost effective. Some surveys are simple by nature (a
few questions with multiple choices), while others are more
complex. The fewer questions asked, the better you can retain a
user's attention and patience. Hence, in a good survey, only
questions relevant to each individual circumstance should be asked.
This article presents a solution for developing an application that
decouples the surveying content and logic from the application.
Terry N. Ngo,
June 2003
Java Tip 138: Still parsing to generate your JavaBeans' XML representation?
Empower your JavaBeans to handle data conversion to and from their
XML document format without complicating the code. This tip shows
you how to write and use a component to convert a JavaBean to its
XML document representation and vice versa.
Paulo Caroli,
May 2003
Java Tip 137: Manage distributed JTables
When displaying tables with tens of thousands of rows (or more), it
is imperative they quickly respond and display. One way to achieve
this is by using a specialized TableModel that
retrieves data from a server only when it is required, thereby
minimizing data download. To further improve efficiency, row data
can be retrieved in chunks of 50 rows and cached on the client side
for future use. This article explains how to write such a
distributed table and presents some of its advantages.
Jeremy Dickson,
April 2003
Java Tip 136: Protect Web application control flow
Struts, from the Apache Jakarta Project, implements the
Synchronizer Token pattern to prevent duplicate form submission.
Applying this pattern, you can detect this situation and follow an
alternate course of action when it happens. But which alternate
action? In most cases, the best solution would be to simply recover
the first submit's result. This tip suggests a simple strategy to
achieve that goal.
Romain Guay,
March 2003
Java Tip 135: Layer and compare property files
Are you still using one big property file? Using multiple property
files instead can also be unwieldy, unless you have the right
tools. You can layer property files easily when you use the
PropDiff utility. Layered property files are good for separating
settings that change for development modes like coding, testing,
and deploying, and for different developers. Written by Paul
Baclace, PropDiff can find the union, intersection, and difference
between property files.
Paul E. Baclace,
February 2003
Java Tip 134: When catching exceptions, don't cast your net too wide
In contrast to some other languages, Java's simplicity and
consistency allow compilers to detect many more errors. Java
developers learn to rely on their compilers to catch assignments to
incorrect types, calls of nonexistent methods and—this
article's topic—incorrect exception handling. But situations
still crop up where you really need to know what you're doing. If
you understand exactly how Java allows you to throw and catch
exceptions, you'll know when you need to be extra careful and what
practices can keep you out of trouble.
Dave Schweisguth,
February 2003
Java Tip 133: More on typesafe enums
Published in early 1997, "
Java Tip 27: Typesafe Constants in C++ and Java" discussed how
to create and use typesafe constants (enums) in both Java and C++.
Since then, various JavaWorld articles have covered how to
enhance this idiom's canonical form and probably more importantly,
documented the problems related to serialization. In this
Java Tip, Phil Bishop presents a simple abstract
class that solves the main serialization issues for you.
Philip Bishop,
January 2003
Recommended: Sing it, brah! 5 fabulous songs for developers
JW's Top 5