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 java.net, 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="http://www.javaworld.com/weblogs/cprog/archives/000315.html">
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="http://www.oreilly.com/catalog/unitest/">Unit Test
Frameworks sets out to fix in href="http://www.onjava.com/pub/a/onjava/2004/11/17/agileuser_1.html">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
Communities
, The new href="http://community.java.net/portlet/">Portlet community is
featuring a book excerpt href="https://portlet.dev.java.net/files/documents/1654/7285/file_7285.dat?filename=sample%20booklet%5flinwood%2dminter%2epdf">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
environment."

From the Mac Java
Community
homepage: Apple's href="http://www.apple.com/downloads/macosx/development_tools/">Development
Tools page is featuring href="http://www.apple.com/downloads/macosx/development_tools/jdock.html">
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
split-panes.


. In today's href="http://forums.java.net/jive/index.jspa"> Forums,


In today's java.net
News Headlines
:

Registered users can submit news items for the href="http://today.java.net/today/news/">java.net 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="http://today.java.net/pub/q/news_rss?x-ver=1.0">java.net
News RSS feed.


Current and upcoming
Java Events
:

  • November 27 href="https://hkjug.dev.java.net/servlets/NewsItemView?newsItemID=1428">Hong
    Kong JUG - J2SE 5.0 Update
  • December 6-9, 2004 href="http://www.theserverside.com/architecture_workshop/index.html">
    TheServerSide Enterprise Java Architecture Workshop
  • December 7-8, 2004 href="http://jini.org/meetings/eighth">Eighth Jini Community
    Meeting
  • December 13-17, 2004 href="http://wiki.javapolis.com/">JavaPolis, 2004

Registered users can submit event listings for the href="http://www.java.net/events">java.net Events Page using our href="http://today.java.net/cs/user/create/e"> 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
Java
Today RSS feed
. Also, once this page is no longer featured as the
front page of java.net it will be
archived along with other past issues in the href="http://today.java.net/today/archive/">java.net Archive.

Efficiency notes from coffee to code