dev@glassfish.java.net

Re: dangerous code pattern

From: Matthew L Daniel <mdaniel_at_scdi.com>
Date: Fri, 31 Mar 2006 08:08:50 -0500

> This has been modified in 1.6
>
> > if (children.item(ii).getFirstChild() != null) {
> > jdbcResource.setDescription(
> > children.item(ii).getFirstChild().getNodeValue());
> > }

Isn't this just as bad, on two separate occasions:
1. it still allows for children.item(ii) to be null
2. (this one is a personal pet peeve) it requires traversing the DOM
   twice because children.item.firstChild was not stored in a local
   variable
2.1. as a side effect, it also makes the lines longer (and thus harder
     to read)

In all honesty, I have not found it to be that much extra typing in
exchange for the clarity and robustness it brings to the codebase.

  My USD$0.02,
  -- /v\atthew