I'm always amazed at the lengths some people will go to 'enterprise up' there Java apps," Ben writes, "especially those daft Yes/No enums that we've seen here lately."

"Now, I've always been proud that I am a practical common-sense programmer, so imagine my surprise when I found myself writing this joy of over-engineering ...

public class NotNull implements Rule {
  String objName = null;
  Object o = null;
  
  public NotNull(String objName, Object o) {
    this.objName = objName;
    this.o = o;
  }
  
  public void check() throws RuleException {
    if (o == null) {
      throw new RuleException(ErrorMessages.ErrorCode.OBJ_IS_NULL, objName);
    }
  }
}

"And its ease of use...

// Make sure the XML is not null
addRule(new NotNull("xml" , xml));

"Why I couln't have just tested for 'null'? I'm not sure, but it all seemed great at the time. And the worst thing is... that code is still there. I must be turning into an "Architect" or something. Help!"

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!