Modified:    src/blocks/scratchpad/java/org/apache/cocoon/ant
                        AntBuildGenerator.java CocoonTask.java
  Log:
  Using commons.lang

- private static final String EMPTY_STRING = "";

- MSSG_ATTRS.addAttribute(EMPTY_STRING, PRIORITY, PRIORITY, CDATA, null);
- NAME_ATTRS.addAttribute(EMPTY_STRING, NAME, NAME, CDATA, null);
+ MSSG_ATTRS.addAttribute(StringUtils.EMPTY, PRIORITY, PRIORITY, CDATA, null);
+ NAME_ATTRS.addAttribute(StringUtils.EMPTY, NAME, NAME, CDATA, null);

I hereby propose to patch commons-lang to include a couple more utility values like:


public class ObjectUtils {
  public static final Object NULL_OBJECT = null;
}

public class NUMBER_UTILS {
  public static final int ZERO = 0;
  public static final int ONE = 1;
}

public class BooleanUtils {
  public static final boolean TRUE = true;
  public static final boolean FALSE = false;
}

assuming they're not already there.

It should be obvious to anyone that the usefulness of this is to ensure that, should, one day, the meaning of "empty string", "null value", "true" or "zero" change, we can apply the change it in one place. God have mercy of those poor souls who will have to hunt through thousands of source files for every occurrence of "" and change it. Fools!

And with the aim of reaching 100% test coverage, our job wouldn't be complete without a comprehensive test suite:

public void testNullIsNull() {
  assertIsNull("NULL_OBJECT is not null", ObjectUtils.NULL_OBJECT);
}

public void testZeroIsNotOne() {
  assertNotEquals("Zero is one", NumberUtils.ZERO, NumberUtils.ONE);
}

and so on...

Ugo



Reply via email to