You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Gary Gregory <gg...@seagullsw.com> on 2003/07/15 18:07:55 UTC

RE: [lang] Pre 2.0 - StringUtils.isEmpty(), isNotEmpty() and stri ngsa with somespaces

I do like the idea of a standard pattern for the isNotFoo() methods.

I am still wondering about the need for these methods in the first place. Of
course, these are pretty low level guys in the library's vocabulary and they
could make some app code more legible to some people, so if folks really
think they add more value than doing

if (!StringUtils.isFoo()) {
}

or

if (StringUtils.isFoo() == false) {
}

then go ahead. ;-)

But, in general, I am not sure we should add "not" methods all over the
place unless there is a good reason to do so.

Gary

-----Original Message-----
From: __matthewHawthorne [mailto:mhawthorne@alumni.pitt.edu] 
Sent: Tuesday, July 15, 2003 08:26
To: Jakarta Commons Developers List
Subject: Re: [lang] Pre 2.0 - StringUtils.isEmpty(), isNotEmpty() and stri
ngsa with somespaces

I agree that having both is/isNot methods is convenient, but I also find 
it slightly confusing, and it adds more code to maintain.

However, as long as they conform to the standard of:

boolean isNotEmpty(String s) {
    return !isEmpty(s);
}

it will at least keep the code easily maintainable.

Thoughts?




Todd Jonker wrote:

>Matt, thanks for your comments.
>
>I guess you're right, we should probably add all of the negated calls:
>
>    isEmpty           isNotEmpty
>    isWhitespace      isNotWhitespace
>    isTrivial         isNotTrivial
>    isBlank           isNotBlank
>
>This morning I'm feeling like they should all be "isNotSomething" for the
>sake of uniformity with most other code.  At least there's only one that's
>incorrect English (to my ears, at leas).
>
>I certainly don't object to the negated methods, it's just that I tend to
>prefer the streamlined API.
>
>..T.
>
>
>On 7/15/03 4:34 AM, Matthew.Hope@capitalone.com wrote:
>
>  
>
>>As a user I agree with the benefits of both proposals (can't decide which
I
>>prefer yet). When I saw the initial proposal I wasn't happy either but
could
>>not come up with a 'complete' solution either.
>>
>>one point on the first though, I would find in my code that the vast
>>majority of my use cases would be
>>
>>if (! isTrivial(s)) {
>>// do something that assumes a non null / length() > 0 string
>>}
>>
>>I dislike overuse of (! someMethod()), especially since I started doing
code
>>maintenace with the help of back browse facilities which find method usage
>>(rather than more fallible regexp). I would therefore like isNonTrivial(s)
>>to be provided.
>>
>>Matt
>>
>>    
>>
>>>-----Original Message-----
>>>From: Todd Jonker [mailto:tvj@pobox.com]
>>>Sent: 15 July 2003 02:39
>>>To: hen@umbongo.flamefew.net; commons-dev@jakarta.apache.org
>>>Subject: Re: [lang] Pre 2.0 - StringUtils.isEmpty(),
>>>isNotEmpty() and stringsa with somespaces
>>>      
>>>
>><snip>
>>    
>>
>>>I tend to dislike thinks like isNotBlank since it increases
>>>the number of
>>>methods one needs to wade through, but adds no new semantic
>>>expressiveness.
>>>Also, the methods above would lead to isNotTrivial, where
>>>isNonTrivial is much more natural
>>>      
>>>
>><snip>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org