Annoying Personality Trait: Self-Righteous Ignorance
May 9th, 2008 by BryanI ran across an individual today asking (rhetorically) what you need to do to make a class serializable in java.
My response went something like this:
Have your class implement the Serializable interface, and if you need or want control over how it’s persisted at the stream level, override the readObject and writeObject methods.
At which point the individual began to say things like, “No that wrong. You just need Serializable interface. That interface empty, you don’t have any method to implement.”
I tried to explain that the extra information I gave let you control -how- the object is serialized, but it wasn’t -necessary- to actually serialize (as long as you’re OK with the standard means of doing that). At that point I got, “No. You wrong. Serializable empty interface.”
My response, “Well, I guess I gave you more information than you wanted. Sorry about that.”
Holy freakin’ crap. Talk about dense, ignorant, and self-righteous. I know what I’m talking about. Marrow-MUSCLE uses many of the concepts of serialization to handle object graph transformations to and from Muscle messages. It does it like this. While this isn’t a perfect example of overriding the Serializable format normally used by java, it does demonstrate that you have to know what you’re doing with serialization in order to accomplish the task.
In the past, I’ve even changed the way writeObject and readObject work on a few projects, just to save bandwidth when implementing an object storage & transfer protocol.
Needless to say, I don’t think very highly of the individual who was so indignant that I was wrong, when all I did was give more detail than they were asking (or apparently aware of).
Moral of the story: If you ask a question like this, and get an answer you don’t expect, or is more detailed than it should be, as the person responding to explain what they’re talking about instead of being self-righteous, ignorant, and indignant that they’re totally wrong.
