Re: Top Ten Errors Java Programmers Make
Additya wrote:
Hello friends , Here is a nice article which I have found while
surfing , it is about the ten common errors which may be made by any
Java Programmer while Programming. The article lists all those
mistakes and their solution.
alexandre_paterson@yahoo.fr wrote:
This article contains mistakes and does *not* give good solutions.
Astounding that a spammer would spam for something not worthwhile, simply
astounding!
I'll give you some but first:
Java refers to what the other refers as 'functions' as 'methods'.
Some of still call them "functions" informally, also "routines" or
"subroutines". They definitions fit even though they be not politically
correct any more.
10. static
Yup, Java fuxx0red big one on that. From an OO point of view the
static concept is heresy. From a unit testing point of view it's
"Heresy" is not a concept properly applicable to engineering, because dogma is
the only heresy.
....
1. NullPointerException?
OMG... Did the 90's called to tell they want their NPE back?
I'm using @NotNull since JetBrains made it available in
IntelliJ and now IntelliJ is free so there's zero reason
not to introduce some DbC into Java... From an OO point
of view the very concept of a null reference is *very*
discutable. So come on, start @NotNull'ing your entire
codebase, you won't regret it. We're doing it since
literally years (so long I can't remember).
I don't know what Eclipse/NetBeans support is for the
@NotNull annotation but anyway IntelliJ can be configured
to have these @NotNull be "transparent" for the rest of
the team (the one stuck on mediocre IDEs ;) [flame, flame,
trolling for an IDE war ;]
Annotations do not depend on a particular IDE but on the annotation type being
in the class path. Any Java IDE will support '@NotNull' if you give it the JAR.
Seriously now... I think people that aren't littering their
codebase with @NotNull and final's should be shot (well, to
be honest everything should have been final and modifiable
refs should have been flagged 'var' or something). And
before the retarded comments "but that make the code hard
to read" I answer "collapsing IDEs you donkeys!" (or collapsing
plugins you donkeys!!!).
A pragmatic programmer will commit heresy if this is your dogma, yet still
write decent code, but they'll do it without disagreeing with you, because
dogma aside, you make an excellent point.
It's interesting to see that several of the errors in the
article are due to language defects (coming from the lack of
OO understanding from the Java creators at the time they
created Java: Gosling admitted putting interfaces in because
the concept "seemed to work" in other language and later
regretted putting the abstract keyword in and allowing
implementation inheritance, he regretted not having gone "pure
interface").
Citation, please.
The 'static' SNAFU, the implementation SI / interface MI f*ckup,
the hascode()/equals(...) retardedness... Not very OOish IMHO.
There's opinion, and there's truth. Nothing wrong with 'hashCode()' and
'equals()'.
That said I love Java. But boy do I know its quirks :)
This is one thing to love about Java. Every other programming language seems
to have True Believers. Java stands alone in that pretty much everybody who
uses it bitches about it mercilessly and believes they would have done better,
and pretty much everybody uses it.
--
Lew