cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Antonio Gallardo" <>
Subject Re: cvs commit: cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/ant
Date Sat, 17 Apr 2004 13:31:13 GMT
Ugo Cei dijo:
>>   Modified:    src/blocks/scratchpad/java/org/apache/cocoon/ant
>>   Log:
>>   Using commons.lang
>>   -    private static final String EMPTY_STRING = "";
>> 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;
> }

Exists something similar but not this Object:
> public class NUMBER_UTILS {
>    public static final int ZERO = 0;
>    public static final int ONE = 1;
> }

I think this is not good. It was useful some time ago to define a Boolean,
but in Java it has no meaning. We have Boolean for that.

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

Already we have Boolean.TRUE and Boolean.FALSE in standard java.lang lib:

> assuming they're not already there.

See answer above.
> 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!

I think it is a good programming practice plus:

It saves resources. I think some people then to abuse the Garbage
collector with no reason. Did you really think it is better to make a:

Boolean b = new Boolean(true) instead of

Boolean b = Boolean.TRUE

Both expresion got the same result, but the first innecesary create
another Object on the memory. That later the garbage collector need to
free. This is my POV. The same happen with

StringUtils.EMPTY vs. ""

Users often rant about Cocoon slowness and maybe in part because of abuse
of garbage collector.

> 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);
> }

Cruel sarcasm...

> and so on...

Ask people on jakarta commons why they write this kind of stupid code or
need we to reinvent the wheel over and over to show how smart programmers
we are?

I really believe in the code reutilization. Jakarta commons lang is part
of the core of Cocoon. Why we need to wrote the same code over and over?

In jakarta commons there is also another interesting libs that we can make
use of them:

Best Regards,

Antonio Gallardo

View raw message