OCD code?

if (!empty(fetchResult()) and isObject(fetchResult()) and is_a(fetchResult(), "objectType")) {
  $result = fetchResult();
  doSomethingElse();
}
elseif (isObject(fetchResult()) {
  $result = fetchResult();
}

I think the guy who wrote it was slightly OCD. And he definitely forgot that fetchResult() fetches results… from the database.

After optimizing aforementioned code and singleton-ifying the fetchResult(), number of queries made in one pageload went down to 300 from 800. Our code is just awesome.

Published by

analytik

I started with BASIC when I was 6.

Leave a Reply