james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Noel J. Bergman" <n...@devtech.com>
Subject RE: String.equalsIgnoreCase Considered Evil :-)
Date Mon, 05 Aug 2002 15:52:49 GMT
Dan,

> String command = commandRaw.trim().toUpperCase();
> if ("USER".equals(command)) ...
> This way, you avoid NullPointerExceptions if "command" is null.

In general, I use "literal".equals(object) in my own code.  However, in the
context of the existing method, we already have a check for the initial
string being null, then we have a check after tokenizing to make sure that
we have a token for the command.  And it was less change going from
command.equalsIgnoreCase("LITERAL") to command.equals("LITERAL").  I was
being pragmatic.

> shouldn't any repeated literals be declared as constants

If you are looking for a size benefit, that happens when you have multiple
class files.  One sometimes overlooked place where that occurs is when you
have inner classes, since those become separate class files.

> Just read the subsequent posts on the "comand object",
> and that's way better...

That's where declaring those command strings as static final class members
might come in handy.

	--- Noel


--
To unsubscribe, e-mail:   <mailto:james-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:james-dev-help@jakarta.apache.org>


Mime
View raw message