Archive for the ‘Java’ Category

Just to drive the point home, guess what just brought down our latest release. A combination of Property accessor logic and not knowing what the underlying framework does, or does not do.

Now I believe this to be fairly harmless getter, we keep a history of dates and the current date is the first on in the list (its sorted). So if there is a list, and it has an entry, get the first one otherwise return null. Simple

 public Date getCurrentDate(){
        Collection dates= get(DATE_COLLECTION);
        return dates.size() == 0?null:(Date)dates.get(0);
  return null;  

The problem is only that when checking if we have a list,  it turns out the underlying framework hides the collection away in a hashmap. As a result in some instances the hashmap is touched by infrastructure code which adds a null to it, thus a check to make sure the returned collection is not null need to be in place.

There are three points here

  • Dont put frickin’ logic in proerty accessors
  • Know thy framwework, inside out especially if its hand rolled. You will not get maqilinglists with answers
  • There are good frameworks out there, so If you handroll your framework, make sure it doens’t do stupid things.

//End rant