dev@glassfish.java.net

Re: dangerous code pattern

From: Scott Oaks <Scott.Oaks_at_Sun.COM>
Date: Fri, 31 Mar 2006 10:20:53 -0500

+2

On Fri, 2006-03-31 at 10:16, Qingqing Ouyang wrote:
> +1
>
> Matthew L Daniel wrote:
>
> >>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
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> >For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>