dev@glassfish.java.net

Re: dangerous code pattern

From: Qingqing Ouyang <Qingqing.Ouyang_at_Sun.COM>
Date: Fri, 31 Mar 2006 09:16:01 -0600

+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
>
>
>