News for hackers. Stuff that matters.
Re:New IDE: code bubbles by Retric on Wednesday March 10, 2010 @05:59PM (#1182269)
Try catching a block that does that is actually less code than a long set of conditionals. Granted it's basically saying:

  if (foo != null) if (bar.bar() != null) if (foo.bar().baz() != null) {
  ...
  worked = true;
  }
  if (false == worked ) {/*to do*/}
But, staying on the happy path until you can demo something is often useful. I think the problem is how you transition from demo to production worthy code.
Re:New IDE: code bubbles by alttab on Wednesday March 10, 2010 @10:55PM (#1182884)
if (foo!=null && (a = foo.bar()) && a != null && ...

a = foo.bar() will always evaluate to true as the assignment shouldn't ever fail. Of course, in compiled languages I'm sure there will need to be a declaration of 'a' but if there is a possibility to reuse temp variables then could work.

However, if you are coding in C/C++ (and to a similar extent Java, there really is no way around it.

This could be an example of why hybrid functional, imperative, and object oriented languages are becoming popular because the programmer can pick the paradigm that most suits the problem.

Re:New IDE: code bubbles by guelo on Wednesday March 10, 2010 @08:55PM (#1182587)
That's not the same since you are executing the bar method multiple times.
Re:New IDE: code bubbles by sukuriant on Wednesday March 10, 2010 @10:57PM (#1182887)
If you really want to get picky, return foo.bar().baz().qux() * 2;

Could become:

  Bar bar = foo.bar();
  if(bar == null) handleBarNull();
  else { 
     Baz baz = bar.baz();
     if(baz == null) handleBazNull();
     else { 
        //(assuming qux is a value)
        return baz.qux() * 2;
     }
  }