On Tue, Oct 11, 2011 at 12:43 PM, Charles Wilt <charles.wilt@xxxxxxxxx> wrote:
In any event, even if we consider an empty string to be
non-null, I agree with Jon that the only tests that make
sense is EMPTY and NOT EMPTY...
If you accept that an empty string is a valid string and is not null,
then what makes the most sense is to allow the empty string to be
compared against any other valid string. With a single test.
What you are saying is that any time you want to compare two arbitrary
strings, you must perform up to three tests. First, you must test
whether one string is empty, then you must test whether the other
string is empty. Then, and only then, IF both strings are not empty,
THEN you can perform a third test to actually do the comparison.
Does this make sense? Is it practical?
I cannot stress enough that some systems DO treat the empty string as
null. For that case, it is reasonable to require a separate check for
null versus not null (i.e. invalid value versus valid value; we can
only reasonably be expected to compare two valid values). But for the
case where the empty string is just a regular, valid, everyday string
that HAPPENS to have a length of zero, then it is absolutely and
utterly reasonable to allow it to be compared to any other valid
string. And it would be ludicrous and illogical not to.
John Y.
As an Amazon Associate we earn from qualifying purchases.