dev@glassfish.java.net

Re: dangerous code pattern

From: <vince.kraemer_at_Sun.COM>
Date: Fri, 31 Mar 2006 07:50:04 -0800

I have noticed a number of places where there is code like

if (a.b().c().d() != null)
  a.b().c().d().dosomething();

Most of the time this is "safe", but it does open the door to bugs down the road..

The author of this pattern is trusting that b(), c(), and d() are side-effect free.

If the author of those methods were to change them (and introduce a side-effect),
this client could have a nasty surprise...

Long live intermediate results!

vbk

----- Original Message -----
From: Scott Oaks <Scott.Oaks_at_Sun.COM>
Date: Friday, March 31, 2006 7:20 am
Subject: Re: dangerous code pattern

> +2
>
> On Fri, 2006-03-31 at 10:16, Qingqing Ouyang wrote:
> > +1
> >