Showing posts with label the ick factor. Show all posts
Showing posts with label the ick factor. Show all posts

Sunday, December 20, 2009

classes that override equals should override hashCode

I was talking to a developer the other day who admitted to me that he had only recently found out that in Java, if you override the Object equals method, you should override the hashCode method also. He had been introduced to this practice by a checkstyle rule.

This surprised me for a couple of reasons. This developer is not a newcomer to Java, and it's the kind of thing I'd expect an experienced developer to know. I know about it myself from my first forays into Java. It's documented in the API for Object:
Note that it is generally necessary to override the hashCode method whenever this method [equals] is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

But I suppose it's the kind of thing you might miss learning if you come into Java from another object-oriented language, and don't do a thorough job of learning the peculiarities of Java.

The other thing that surprised me was the fact that he admitted it at all. Developers rarely confess to ignorance. I guess that admitting a weakness is just too dangerous in this highly competitive field. I tend to be pretty open about my own gaps in knowledge, but I suspect it doesn't help me any, and in some cases it may hurt. Have you ever said "gee I didn't know X" and gotten a snooty look down the nose from someone? Not the kind of experience you want to repeat!

Tuesday, June 30, 2009

people that you meet

The crowd at the conference
photo by Stephan Ridgway by use under cc license

Recently, I was having a discussion with an unemployed software developer. I will refer to him as X (just so we're clear, "X" is not his real name).

X had a few words to say about taxes and the attempts to nationalize health insurance; he was against both. I didn't get to dig much deeper because we were in the midst of discussing something else, but I did disagree with him immediately on the latter point, since I am perfectly happy to try nationalizing health insurance. He later mentioned to me that while he was unemployed, a huge part of his health insurance was being covered by the government-run stimulus plain. He seemed to be happy about that.

X told a story about a guy he knows who is on disability, who gets all of his health care provided for by the government, and who, in addition, is taking off for a three-week vacation. I wasn't quite sure what the moral of his story was. But it sounded a lot like he was ranting about how such people cheat the government and steal his tax money.

X is taking a few weeks of vacation in August. He indicated that he was planning on drawing unemployment compensation while he's on vacation. I urged him not to, pointing out that it's illegal and unethical.

While discussing these things, I tried to keep polite when disagreeing. My natural tendency in such situations is to avoid conflict, neither disagreeing or agreeing, and to move the conversation along away from hot-button issues. And later, I try to avoid getting into discussions with the person. Possibly I'm overly non-confrontational (<sarcasm>is that because I'm female?</sarcasm>), but I don't see any point in getting into random arguments with strangers. I'm not sure what to do in this case. I met X at a professional meeting, and was hoping that he'd be a good networking contact, but I think I was mistaken. This most recent conversation gave me a pretty big "ick" factor. How picky should you be with your networking contacts, anyway?