Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why one Super Class?

 
Ramaswamy Srinivasan
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Author Jacquie / My fellow ranchers,

We all very well know that all the classes extend "java.lang.Object".

I was just thinking, why was such a design made. What are the advantages, that would be the fruits of this particular behaviour.

Care to explain?

Cheers,
Ram
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well in my view, everything is an object so some *qualities* that all should have (quality of object because all are object) are kept in Object class and all classes are implicitly sub class of Object.
 
Vasilis Karas
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ram,
let me complement your question and ask why not? Is there a limitation that you've encountered??
This question is one for the true computer scientist which I won't pretend to be.
My guess would lead me to what the proponents (I'm included) of Java hail as it's greatest benefits:

1)Built as an easy to use and pure OO language
2)Is platform independent
3)Built with multi-threading in mind--

Hopefully all see these as fairly accurate statements...

These attributes most likely required a common superclass so our beloved JVM (platform specific) can work appropriately: regaining memory on any system (gc) and control it's threads (wait(), notify(), notifyAll())...

A more creationist view may be that because all matter (Objects in this case) be created from one source

 
Ramaswamy Srinivasan
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vasilis,

Thanks for the post. I agree with you.

By the way, i did not face any limitations, with this implementation.

I have thought of all these common features in a single place holder, easy to implement,OO, etc...

But the perspective in which i had put my question here is to just know what was the design condition, beyond all these, and how it helps in the internals of the JVM, other that this gc, threads, etc...

Cheers,
Ram.
 
Junilu Lacar
Bartender
Pie
Posts: 7465
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's an article that talks about the benefits of a singly-rooted hierarchy:

http://www.codeguru.com/java/tij/tij0024.shtml
 
Ramaswamy Srinivasan
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Junilu,

This is really a good information. Thanks a lot, for letting me know.

Cheers,
Ram.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic