u johansson

Ranch Hand
+ Follow
since Dec 27, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by u johansson

The main issue is that deprecated methods may, in principle, disappear in future Java versions and thus break your program.
12 years ago

Originally posted by Gregg Bolinger:
The "stupidity" factor of reflection is not what this discussion is about. Start a new thread if you want to discuss that topic further.

Thanks.



Well "stupid" may be a little strong, but reflection basically is a "sin" in a language like Java and should be avoided.

Anyway say you cannot resist the temptation, will reflection degrade performance? Sure, in principle, because certain typing issues cannot be as efficiently resolved as they could without reflection.

The question now is will reflection degrade the performance of a specific application? The answer is as always. Only if it's part of a performance bottleneck. There's nothing special about reflection in this respect.
[ December 30, 2005: Message edited by: u johansson ]
12 years ago


The short answer is that it is handy having a fast way to 'guess' whether two objects are the same, then compare them only when you have to.



There's no reason to assume that hashCode should be a faster way to test for object equality. In fact the opposite is true. Equals is likely to be faster. It's because a good hashCode has to consider the entire content (in order to guarantee an even distribution of hash codes), whereas equals only has to compare content up to the point where it can be established that two objects are not equal. And in addition, hashCode requires you to make two hashCode calls and then an additional call to equals in the case the hashCode ints turn out to be equal. Using equals is always just one call.

So, it's much better to use equals to compare objects for content equality. It's both handier and likely to be faster than (mis)using hashCode for that purpose.
[ December 30, 2005: Message edited by: u johansson ]
12 years ago


what is use of hash code?



Do you mean the hashCode method?

The main use is to allow classes to be used with hash table based collections such as HashTree and HashMap. For that to work properly hashCode (defined in Object) must be overridden in conjunction with equals (also defined in Object).

Both equals and hashCode deal with the content of objects. Equals should return true when two objects are considered equal based on their contents. The rule for hashCode is that if two objects are equal (in the sense that equals return true) the hashCode method of both objects MUST return the same int. BUT they MAY also do that if they're not equal. The latter is called a collision and it's allowed but it should be avoided because it degrades the access performance when such objects are stored in collections.
12 years ago
Illya Preuss:

My advice to the OP was to reconsider the extensive use of Strings. Without knowing the exact details it's often a performance bottleneck.

Regarding your nitpicking - a String array isn't a String. If you feel you need to nitpick make sure you have a case!

Finally I think you should stop sneaking in advertisments for your book. It's extremely annoying and it beats me how people can be so full of themeselves that they don't understand that. If you want to promote something for your own financial gain you should pay pay for ads like everybody else.
12 years ago
Hi Henry Wong,

I've thought a lot about morality, but not especiality about hangman morality.
12 years ago
Hi Klaas Vredevort,

Well, I'm a moral coder.
12 years ago
What is Hibernate?

Is it some API you guys are stuck to?

[Removed unecessary harsh language - GDB]
[ December 27, 2005: Message edited by: Gregg Bolinger ]
Well, the only reason I can find is that you're trying to promote your book isn't it?
12 years ago
Sorry, Ilja Preuss, Huffman coding is based on similarites.
12 years ago
Yes why don't you?

If you wan't slack typing why don't try some other language?
12 years ago
It's so different as to what I consider good programming.

/Ulrika
12 years ago
Well, make sure you do it at the highest abstraction level possible.
12 years ago
You got to know about algoritms & data structures.
12 years ago
Well you read the file and then you write something to the target file.

What's the problem?
12 years ago