«« Next » « Previous
«« Next » « Previous

Link Details

Link 87690 thumbnail
User 185351 avatar

By jsugrue
via java.dzone.com
Published: Jun 16 2008 / 11:00

I read an article (linked below) on “Top Ten Errors Java Programmers Make“. The author has mentioned the errors which even the most experienced programmers often commit or the New to Java programmers may commit in the future. Not only has he listed the errors but also given the possible solution for the same. I found the article really informative.
  • 17
  • 16
  • 1646
  • 993

Comments

Add your comment
User 187417 avatar

sproketboy replied ago:

0 votes Vote down Vote up Reply

First: The link is actually referencing this link: http://www.javacoffeebreak.com/articles/toptenerrors.html
Second: The additional errors mentioned are not too useful since the compiler catches most of these anyway.
Third: The originating link is wrong about pass by reference. Java does not pass by reference. It passes a copy of the object pointer. Not the same thing. In C++ for example a method can null an object which affects the calling method - in Java



User 187417 avatar

sproketboy replied ago:

0 votes Vote down Vote up Reply

in Java (stupid dzone doesn't let you edit your reply) - that can't happen as you'd be only nulling out the copy of the reference.

User 285418 avatar

Motion Control replied ago:

0 votes Vote down Vote up Reply

In short, Java reference == C pointer

User 187417 avatar

sproketboy replied ago:

0 votes Vote down Vote up Reply

I think C has the same issue as C++. A function can destroy the struct pointed to in a parameter if you're not careful. I haven't coded C in like 18 years so I can't give an example. :(

User 209464 avatar

willcode4beer replied ago:

-1 votes Vote down Vote up Reply

The whole pass by reference/copy argument/confusion would not exist if programmers quite making the number one mistake, "writing methods with side effects".

User 285418 avatar

Motion Control replied ago:

0 votes Vote down Vote up Reply

I'd happily write my programs in a functional language if I only had a stateless database.

User 288015 avatar

noahz replied ago:

0 votes Vote down Vote up Reply

Agreed - most of the errors are compiler errors.

User 191349 avatar

raveman replied ago:

3 votes Vote down Vote up Reply

i think its not funny,but very stupid. its like always misspelling your name.but to be fair it happens all the time to people that have name longer than 10 chars, so i heard(i just copy and paste mine).

-vraeman
-raveman(sorry, i dont know how to delete the line above, can someone help? i cant remember what button to press, its so hard).

continue; (ups, again i wrote it not inside the loop)

P.S. topic should be top ten errors that idiots make. (i dont even try to be mean, its just very sad and offensive to java programmers). I make mistakes, but its not like i would bite my hand when i eat.

User 272422 avatar

htowninsomniac replied ago:

0 votes Vote down Vote up Reply

The original "Top Ten" list is a list of errors that only beginners make. The errors jsugrue added in his post are only marginally more complex. Perhaps the lists should have been called "Top Ten Mistakes Java BEGINNERS Make".
I also object to the description of argument passing. Everything in Java is passed by value. When you pass an object, you just happen to pass a reference to it, not the object itself; that reference, however, is passed by value and cannot be changed. Perhaps some might consider this as nitpicking, but it describes another relatively common mistake of beginners, namely changing the value of a parameter and expecting the change to be visible outside the method.
The most dangerous error in both lists combined is misspelling a method when overriding. That actually happens quite frequently, even to seasoned programmers, and contrary to most errors in the lists this one cannot be caught by the compiler.

User 187417 avatar

sproketboy replied ago:

0 votes Vote down Vote up Reply

You're right. Misspelling an override is not caught by the compiler. Good reason to follow the advice of favoring composition over inheritance when possible.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.