Skip to main content

Order matters

Posted by daniel on November 26, 2004 at 8:38 AM PST

Efficiency notes from coffee to code

Each morning after updating, I head downstairs to make
coffee and take care of our dog. The order in which I address the
tasks depends on which method of coffee preparation I'm using. I
prefer to use the vacuum brewing method - in which case the water
needs to come to a boil before anything else much can happen. This
means that step one is fill the pot with water and set it to
boil. Then feed the dog. Grind the coffee while she eats. Put in the
top part of the brewer, insert the stopper, add the grounds, and set
the timer for three minutes. Let the dog out.

If instead, I decide to use a drip coffee maker, the changes. I
might as well get the dog food on my way in to the kitchen. As I pass
the grinder, I pause with the dog's food still in hand to set the
grind and start the process. Feed the dog. Fill the coffee maker with
water and the grounds and flick the switch. Let the dog out.

This labored look into my morning schedule was sparked by a blog
on improving performance in your code from JavaWorld magazine. In the
kitchen, you smooth out your day by considering which machines you
will just end up waiting on. The same is true in your code - I know
you aren't supposed to prematurely optimize, but if your code is not
performing as you would expect, the blog contains a reason that I'd
never considered. It's arises from the order of evaluation of the JVM.

In Also
in Java Today
, as you look to improve the performance of
your code, href="">
Be Careful of Premature Parameter Construction. Ray Djajadinata
writes an investigation into code in which "It turned out that an
old (but unfortunately huge) part of our app was sprinkled with
method calls like this:

logger.debug("parameters: " + parameters.toString());

These thousands of string concatenations still happened although we
had turned disabled the DEBUG logging level, because the string
concatenation (and the call to parameters.toString()) happened before
the debug() method is even called! This "unwanted parameter
construction" is mentioned very clearly in log4j's FAQ and javadoc,
but... people do forget."

"What is preventing people from building GUIs in an Agile way? Whether
their application is web-based or a desktop application, most
developers don't do test-driven development (TDD) of the user
interface. This is for a simple reason: unit testing GUI software is
hard." This is the problem that Paul Hamill, author of href="">Unit Test
Frameworks sets out to fix in href="">Agile
User Interface Development. By splitting his GUI elements into
"smart objects" and "thin views", he maximizes the functionality that
can be exposed to testing.

In Projects and
, The new href="">Portlet community is
featuring a book excerpt href="">Building
Portals with the Java Portlet API . "Several example portlets are
developed to give you hands-on portlet experience. You'll even learn
how to port existing servlet and JSP applications into a new portal

From the Mac Java
homepage: Apple's href="">Development
Tools page is featuring href="">
JDock, a Swing-based framework for managing inner windows or
components, using common layout managers like BorderLayout or
GridBagLayout. It allows you to dynamically add and remove actions,
save and restore the state of your environment, and avoid using

. In today's href=""> Forums,

In today's
News Headlines

Registered users can submit news items for the href=""> News Page
using our news
submission form
. All submissions go through an editorial
review before being posted to the site. You can also subscribe to
the href="">
News RSS feed.

Current and upcoming
Java Events

  • November 27 href="">Hong
    Kong JUG - J2SE 5.0 Update
  • December 6-9, 2004 href="">
    TheServerSide Enterprise Java Architecture Workshop
  • December 7-8, 2004 href="">Eighth Jini Community
  • December 13-17, 2004 href="">JavaPolis, 2004

Registered users can submit event listings for the href=""> Events Page using our href=""> events submission
form. All submissions go through an editorial review before being
posted to the site.

Archives and Subscriptions: This blog is delivered
weekdays as the
Today RSS feed
. Also, once this page is no longer featured as the
front page of it will be
archived along with other past issues in the href=""> Archive.

Efficiency notes from coffee to code