This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

regarding serializatiotion

 
Saral Saxena
Ranch Hand
Posts: 203
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks,

Could you please advise me the technical reason that why the Object class was not made to implement the serializable interface..!
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Saral Saxena wrote:Hi Folks,

Could you please advise me the technical reason that why the Object class was not made to implement the serializable interface..!

Not always do you want to serialize the object, and not all objects are going to be serialized.
 
Saral Saxena
Ranch Hand
Posts: 203
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohamed Sanaulla wrote:
Saral Saxena wrote:Hi Folks,

Could you please advise me the technical reason that why the Object class was not made to implement the serializable interface..!

Not always do you want to serialize the object, and not all objects are going to be serialized.


Hi ,

could you please come up with any technical example that will make understandings more clear..!!
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont know the real technical reason, but I can think of it. I dont think its a good idea to unnecessarily extend/implement classes/interfaces (even though they might be just Marker interface). If they are not marker interfaces then you would end up polluting the class with unnecessary implementations, extensions.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Saral Saxena wrote:
Mohamed Sanaulla wrote:
Saral Saxena wrote:Hi Folks,

Could you please advise me the technical reason that why the Object class was not made to implement the serializable interface..!

Not always do you want to serialize the object, and not all objects are going to be serialized.


Hi ,

could you please come up with any technical example that will make understandings more clear..!!


What's not clear? We only want some classes to be serializable, not all. If Object implements Serialzable, then everything would implement it, and we don't want that.
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An interface cannot be "unimplemented". If the Object class implemented the Serializable interface, all Java objects would inevitably implement it as well, and subsequently there would not be any need for that interface at all. The way it is now, a class designer can choose whether his class should or should not implement that interface and can therefore decide whether the class will be serializable or not.
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Saral Saxena wrote:Hi Folks,

Could you please advise me the technical reason that why the Object class was not made to implement the serializable interface..!


And if in case they did, you already know from this thread, what wrong it can do.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic