compare with empty string uses equals method or == ??

H

Hemal Pandya

Tony Morris said:
Hemal Pandya said:
Tony Morris said:
I usually declare my 'public static final's to as String rather then
int for a somewhat safe usage, as a compromise in absence of enums. I
would appreciate any comments you may have on this scheme.

Comment: poor form.
Investigate the Type-safe enumeration design pattern.

Which type-safe enumeration design patterns are you referrning to? I
know of only one with some choices in implementation (one object per
element or one type per element). [....]
What makes you think I don't know about it? I was talking about a
lightweight alternative; type-safe enumeration, the way it is
usually described is too much code for too little syntactic sugar.

The way it is described is additional code and a slight performance hit for
more robust and maintainable software.
I (almost) always sacrifice performance for maintainability - it costs less
for a hardware upgrade than maintaining poorly written software.

Perhaps you did know about it?

I knew about it. I was asking about others; since your suggestion
implies (no assumption needed) that there is more then one pattern
that provides type safe enumeration.
Your suggestion implied (with asumption of ourse) the contrary.

Well, I happen to know about it, perhaps you assume too much? But as I
said earlier, too little syntactic sugar for too much code, at least
for my taste. Working in the real world, I find the Strings a good
compromise.

Yes, the check is at compile time in stead of runtime. But it does not
have the false positive of an int.
 
T

Tony Morris

Yes, the check is at compile time in stead of runtime. But it does not
have the false positive of an int.

I don't understand why you'd ask for comment if you already knew about a
more robust and maintainable solution.
I also don't understand the comment "String is better than an int since it
does not have the false positive".
Neither is better than the other - they are both poor implementations of
"enumerations".

In your given example, I was forced to assume that the types are in fact
type String (since, as it currently stands, the example will not compile).
This assumption was based on the fact that the reference is assigned to a
String - also the fact that your description says that it is of type String.
A further comment on the fact that it is "poor form" is also the fact that
passing in: new String("one") will cause a runtime failure, which might be
the intention or it might not; either way, it is misleading to the user of
the API.
Furthermore, a java.lang.IllegalArgumentException is more appropriate than a
"RuntimeError".
This comment assumes that RuntimeError is some class you have made up that
is a subclass (direct or not) of java.lang.Error.
I have more comments that could be made, but I'm unsure of your request i.e.
"Can you please give comment but only if I don't already know about it?".
i.e. How the f!@# am I supposed to know what you know? And even if I did,
why are you asking redundant questions?

Conclusive comment: poor form.

--
Tony Morris
(BInfTech, Cert 3 I.T.)
Software Engineer
(2003 VTR1000F)
Sun Certified Programmer for the Java 2 Platform (1.4)
Sun Certified Developer for the Java 2 Platform
 
H

Hemal Pandya

Tony Morris said:
I don't understand why you'd ask for comment if you already knew about a
more robust and maintainable solution.

Yours was less of a comment and more of a verdict, with no rationale
provided. Next time I need a yes or no answer I'll send you e-mail;
otherwise please resist the temptation to follow up.
I also don't understand the comment "String is better than an int
since it does not have the false positive".

Look up the meaning of false positives. Then think of the typical
checks -- if (param != ONE && param != TWO) -- how they will evaluate
with a wrong call.

[....]

Well, this indeed is "comments". Thanks.
 
R

Roedy Green

Yours was less of a comment and more of a verdict, with no rationale
provided.

I get emails like that people asserting something I consider counter
to common sense, then they follow up angry email I did not change my
website just on their say so. After all, THEY know they are better
informed than I, but it is not obvious to me. The problem is, cranks
often sound much the same. The main thing you have to go on is the
emotional tone.

When someone insists I believe something without evidence, it seems to
me, most of the time, he is bluffing.

I think sometimes people like to offer controversial statements
without evidence on newsgroups as a test of status. If the comment
passes without discussion, it would be proof you were one of the gods.
In actuality, it probably just meant nobody cared about the issue.

The Internet is a great leveler. With it I was able to browbeat the
mayor of Victoria and really get him going. Yet in person, he has all
the pomp of office to put me down. Sometimes I think people on the
Internet expect the rabble to treat them with the same esteem their
those in next office do. Nobody in the newsgroups can see the leather
couch or the private washroom.
 
T

Tony Morris

Hemal Pandya said:
Yours was less of a comment and more of a verdict, with no rationale
provided. Next time I need a yes or no answer I'll send you e-mail;
otherwise please resist the temptation to follow up.

I spent quite a lot of time justifying the reasoning behind it after you
asked for it.
Initially, I assumed that you had the initiative to look it up for yourself
to determine why I gave my brief comment. What puzzled me (and still does)
was that you claim you already know and understand my reasoning, yet you
make suggestions to the contrary.
Look up the meaning of false positives. Then think of the typical
checks -- if (param != ONE && param != TWO) -- how they will evaluate
with a wrong call.

I'm aware of what a false positive is. I assume that English is not your
native language. I "deciphered" some of your sentences, but this one is too
ambiguous - please clarify.
"how will they evaluate?" - see my previous and relatively lengthy (I don't
get paid to educate $JOE) explanation - this is very different to what a
"false positive" is - perhaps you need to understand this term.

Is this just an ego thing?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top