Vladimir Nesov

Greenhorn
+ Follow
since Jun 18, 2006
Merit badge: grant badges
For More
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
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Vladimir Nesov

Even if you don't write anything in getter/setter at the moment, having them enables you to do so later without changeing code that uses those properties.
17 years ago
Problem is that it changes even when fields set doesn't change. Even if serialization is used to transfer objects, there may be different versions of application of connection ends. Only case when it doesn't matter is some sort of spooling, but when you are able to store most of application data there appears some new application for storing/sending, so compatibility again.
17 years ago
There's serialver tool in the same directory where java is which can calculate current serialVesionUID. Point in defining this variable is to enable compatibility with old versions your your class, that is if you do define this variable you should be prepared to read serialized oblects of earlier versions with the same serialVesionUID.
17 years ago
Generic declarations don't directly affect performance. They matter only compile time.
Btw, it's strange to see HashMap in parameter declaration, it should be possible to use Map instead. In this particular case it may be better to wrap whole HashMap<String,RHSRATE> part in its own class, so that you use only Iterator<Entry<LHSRATE, MyMappingClass>>. In many cases readability may be preferred over performance, so you may consider using this inefficient loop:

[ August 08, 2006: Message edited by: Vladimir Nesov ]
[ August 08, 2006: Message edited by: Vladimir Nesov ]
17 years ago
Object graph is being traversed, as I got it from implementation, in depth-first order. It may be important if object being saved contains many cross-references. If such DFS tree is too deep, it'll result in stack overflow. If while reading restoring code relies on part of graph not yet read, it'll end in some wrong behaviour. You can modify order by explicitly encoding it in readObject/writeObject methods.
17 years ago
Thanks, I'll keep it in mind, though it's all the same as an answer to 'why Java 5 compiler gives a warning?".
[ July 02, 2006: Message edited by: Vladimir Nesov ]
17 years ago
Yes, that's right. Nice trick with replacing in-stream. I used to add writeReplace() to third-party code.
17 years ago
It's possible to redefine equals() method and still obey the contract. To do it, compare object's getClass() to getClass() of object implementing equals(). Also don't forget to implement hashCode() alongside equals().
[ June 29, 2006: Message edited by: Vladimir Nesov ]
17 years ago
Also note that 10/2*5 is 25, not 1. You wrote wrong in your formulae.
17 years ago
When you call non-static method, which method is really called depends on contents of object you call it on.
If object is an instance of one derived class, method defined for that class will be called. If you call it on instance of another class - another class will be called. Class of object isn't always known at call site, so code actually accesses object method called on.
So as you call static methods without any specific object, there's no information to decide based on which method is to call.
17 years ago
It means that standard way of implementing enums was as you quoted, that is using integer constants.
Note that typesafe enum pattern was still not significantly more difficult, and enum keyword is just some syntactic sugar upon such pattern.
17 years ago
With replaceAll it's decline to workd on original (Windows) system. It's better to create method which would create File object manually parsing path in known format.
17 years ago
Note that the whole point of File is abstraction of system-specific path naming rules, so don't do things like new File("C:\my_folder"). Such things should be outside the code.
17 years ago
Instead of thisyou should have list of pattern to match as error codes corresponding to them like in(better yet create structure for pattern, but that would be overkill here). It's against code duplication.

Instead of this:simplier to create a collection and then check all its elements for this condition. This way you'd only specify in single place what you want of all these String things:(it'd be better to create structure to manage that information and check information correctness while initializing it (within it))


P.S. Whole point: write it like this and you'll never loose that ';' after 17th if statement.
[ June 29, 2006: Message edited by: Vladimir Nesov ]
17 years ago
I usually just browse API source within the IDE as I write code that uses it.