Bookmark Topic Watch Topic
  • New Topic

parent interface  RSS feed

 
savitririnki gupta
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Report post to moderator
Object class is the most parent class in java . Is there any most parernt interface in java ?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Report post to moderator
no
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Report post to moderator
Don't use the word parent when you're talking about inheritance with regard to object oriented programming. Inheritance in the biological sense (which involves parents and children) has a different meaning than inheritance in object oriented programming.

The correct term in Java is superclass: class Object is the topmost class in Java's inheritance hierarchy, and all other classes have it as their superclass.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
Jesper de Jong wrote:Don't use the word parent when you're talking about inheritance with regard to object oriented programming...The correct term in Java is superclass...

Hmmm. While I totally agree that it's good to know the correct terms, I do think that we can be a bit AR about it; and the term "parent" certainly conveys the correct meaning - particularly for a language like Java which only allows single inheritance.

But maybe it's my database background, where the term is used all the time (also often incorrectly ).

Winston
 
Anayonkar Shivalkar
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Report post to moderator
Winston Gutkowski wrote:I do think that we can be a bit AR about it; and the term "parent" certainly conveys the correct meaning - particularly for a language like Java which only allows single inheritance.

What is 'AR'? Also, I think that parent is not a correct term for exactly same reason mentioned above - in parent-child relationship, a child can have 2 parents, but in Java, a class can have only one super-class
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Report post to moderator
Anayonkar Shivalkar wrote:What is 'AR'?

Not 'Accounts Receivable'.
Also, I think that parent is not a correct term for exactly same reason mentioned above - in parent-child relationship, a child can have 2 parents, but in Java, a class can have only one super-class

Actually, in data modelling, a "parent-child" relationship means precisely a 1:many relationship - and moreover, usually a 1:1-or-many (as opposed to a 1:0-or-many, as in the case of a foreign key or subset). I also think think that it conveys the meaning well to newbies, even if it's not technically correct.

But it's just my opinion.

Winston
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
There are at least three commonly-used pairs of terms to describe class relationships, all equally valid IMO:

  • parent/child
  • base class/derived class
  • superclass/subclass


  • All are universally understood and interchangeable.
     
    Jesper de Jong
    Java Cowboy
    Sheriff
    Posts: 16060
    88
    Android IntelliJ IDE Java Scala Spring
    • Likes 1
    • Mark post as helpful
    • send pies
    • Report post to moderator
    In object oriented programming, inheritance means specialization, and there's an "is a" relationship from the subclass to the superclass. For example you could have class Animal and class Dog extends Animal. A Dog is an Animal (it's a specific kind of animal -> specialization).

    Suppose that you have a class Parent and a class Child extends Parent. What that would mean is that a Child is a Parent, which makes no sense at all with regard to be biological meaning of the word "inheritance".

    People already know what "inheritance" means in biology. Suppose that someone is trying to learn OO programming. If you prime their minds with the biological meaning of the word, then it's going to be harder for them to understand that the OO programming meaning of the word is totally different. So it's better to not use words like "parent" and "child" because that will be confusing.
     
    Matthew Brown
    Bartender
    Posts: 4568
    9
    • Likes 1
    • Mark post as helpful
    • send pies
    • Report post to moderator
    You realise that's just as good an argument to drop the word "inheritance" as well?
     
    Campbell Ritchie
    Marshal
    Posts: 56584
    172
    • Mark post as helpful
    • send pies
    • Report post to moderator
    And everybody already knows how “accounts receivable” [ ] I am, so I shall point out that parent and child are used for GUIs where a child appears surrounded by the parent. Another reason to avoid that term.

    The C# terms base and derived are probably the best nomenclature.
     
    Anayonkar Shivalkar
    Bartender
    Posts: 1558
    5
    Eclipse IDE Java Linux
    • Mark post as helpful
    • send pies
    • Report post to moderator
    Jesper de Jong wrote:People already know what "inheritance" means in biology. Suppose that someone is trying to learn OO programming. If you prime their minds with the biological meaning of the word, then it's going to be harder for them to understand that the OO programming meaning of the word is totally different. So it's better to not use words like "parent" and "child" because that will be confusing.

    Agreed
     
    Winston Gutkowski
    Bartender
    Posts: 10575
    66
    Eclipse IDE Hibernate Ubuntu
    • Mark post as helpful
    • send pies
    • Report post to moderator
    Jesper de Jong wrote:In object oriented programming, inheritance means specialization...People already know what "inheritance" means in biology. Suppose that someone is trying to learn OO programming. If you prime their minds with the biological meaning of the word, then it's going to be harder for them to understand that the OO programming meaning of the word is totally different. So it's better to not use words like "parent" and "child" because that will be confusing.

    I see your point, but I think you can carry it too far. For a start, the term already exists in data modelling, where it also has a potentially confusing meaning - in DM, a parent-child relationship usually refers to one where the parent has no meaning without the child (as in the case of an Invoice → Line-Item relationship); and plenty of modellers seem to have survived to work out the difference for themselves.

    When introducing newbies to concepts, you sometimes have to find non-technical terms that have a similar meaning; and to me "parent-child" conveys the idea of a downward, existence-based relationship rather nicely. You can always correct misconceptions later on.

    But, as I say, it's just my opinion.

    Winston
     
    Ernest Friedman-Hill
    author and iconoclast
    Sheriff
    Posts: 24217
    38
    Chrome Eclipse IDE Mac OS X
    • Likes 1
    • Mark post as helpful
    • send pies
    • Report post to moderator
    Jesper de Jong wrote:
    Suppose that you have a class Parent and a class Child extends Parent. What that would mean is that a Child is a Parent, which makes no sense at all with regard to be biological meaning of the word "inheritance".


    "No sense at all" is not just an understatement; it is false. The commonly used is-a is really just a convenient shorthand, and a misleading one at that; for Object has a number of properties that String does not (it has no member variables; it returns its class name as part of toString()'s return value, etc) so in no real sense is a String an Object. Instead, a String is substitutable for an Object, and that aligns rather well with the colloquial meaning of inheritance: a child inherits the characteristics and eventually the property of a parent, and thus goes on to take their place in society. I'd say it's an excellent analogy, one that could easily help someone in understanding the concepts of object-oriented programming.

    In contrast super implies superior, improved, better, while sub implies below, inferior, weaker; and yet those prefixes are used in quite the opposite way in object-oriented parlance. While I agree that base is good and unambiguous, the English meaning of derived is barely aligned with how it's used to describe class relationships.

    I suspect we'll just have to agree to disagree on this, but I wish in the future you'd include "In my opinion" when explaining these beliefs.
     
    Jeff Verdegan
    Bartender
    Posts: 6109
    6
    Android IntelliJ IDE Java
    • Mark post as helpful
    • send pies
    • Report post to moderator
    Jesper de Jong wrote:
    Suppose that you have a class Parent and a class Child extends Parent. What that would mean is that a Child is a Parent, which makes no sense at all with regard to be biological meaning of the word "inheritance".

    People already know what "inheritance" means in biology. Suppose that someone is trying to learn OO programming. If you prime their minds with the biological meaning of the word, then it's going to be harder for them to understand that the OO programming meaning of the word is totally different


    Since the term "inheritance" is already present, and has a different meaning from biological inheritance, the potential for confusion is already there. I don't think using "parent" and "child" adds any confusion that's not already present, and it doesn't take much to explain that OO's IS-A != biological p/c relationship. I think it's fine to use the terms "parent" and "child."

    Where I do think it could add confusion is in GUIs. Aren't the terms "parent" and "child" used when talking about UI elements contained within other UI elements? For a beginner, the distinction between a child class and a child UI element that probably has no type hierarchy relationship to its "parent" could be confusing.
     
    Jesper de Jong
    Java Cowboy
    Sheriff
    Posts: 16060
    88
    Android IntelliJ IDE Java Scala Spring
    • Mark post as helpful
    • send pies
    • Report post to moderator
    Winston Gutkowski wrote:When introducing newbies to concepts, you sometimes have to find non-technical terms that have a similar meaning; and to me "parent-child" conveys the idea of a downward, existence-based relationship rather nicely. You can always correct misconceptions later on.

    I see your point about the "parent-child" relationship, but I still think it fits poorly with what "inheritance" means in object oriented programming (specifically the "is a" relationship). And I think it's better to learn people the right meaning of things from the start rather than to have them unlearn misconceptions later on.

    Ernest Friedman-Hill wrote:"No sense at all" is not just an understatement; it is false. ... Instead, a String is substitutable for an Object, and that aligns rather well with the colloquial meaning of inheritance: a child inherits the characteristics and eventually the property of a parent, and thus goes on to take their place in society. I'd say it's an excellent analogy, one that could easily help someone in understanding the concepts of object-oriented programming.

    Indeed, just "is a" is perhaps too simple (Liskov substitution principle), and I see how the analogy works in the way you describe it. It's more "can be a substitute for" than "is a".

    Ernest Friedman-Hill wrote:I suspect we'll just have to agree to disagree on this, but I wish in the future you'd include "In my opinion" when explaining these beliefs.

    I will. By the way, I'm not disagreeing or trying to argue with you, and I think we have some valuable ideas in this topic.
     
    Winston Gutkowski
    Bartender
    Posts: 10575
    66
    Eclipse IDE Hibernate Ubuntu
    • Mark post as helpful
    • send pies
    • Report post to moderator
    Jesper de Jong wrote:By the way, I'm not disagreeing or trying to argue with you, and I think we have some valuable ideas in this topic.

    Totally agree...and there's nothing wrong with a good argument between people of honest intent (I actually gave you a +).

    Winston
     
    dennis deems
    Ranch Hand
    Posts: 808
    • Mark post as helpful
    • send pies
    • Report post to moderator
    Ernest Friedman-Hill wrote:In contrast super implies superior, improved, better, while sub implies below, inferior, weaker; and yet those prefixes are used in quite the opposite way in object-oriented parlance.

    The literal meaning of super (as well as superior) is above; the literal meaning of sub is below. On an inheritance tree, that literally describes the relationship between the two classes.

    Those prefixes do not imply value judgments at all. There's nothing intrinsically better or worse about being either above or below. Those are simply associations that accrue from words we have arbitrarily built using those prefixes. It's no strain to come up with words which use those prefixes yet don't imply the value judgments you suggest: superfluous, superficial, superimposed, supersonic; subliminal, submarine, subcutaneous, subatomic.
     
    dennis deems
    Ranch Hand
    Posts: 808
    • Mark post as helpful
    • send pies
    • Report post to moderator
    The usage that really sets my teeth on edge is using "subclass" as a verb; to say one class "subclasses" another class. Ugly in every way. What's wrong with saying "extends"?
     
    Jeff Verdegan
    Bartender
    Posts: 6109
    6
    Android IntelliJ IDE Java
    • Mark post as helpful
    • send pies
    • Report post to moderator
    Dennis Deems wrote:
    The literal meaning of super (as well as superior) is above; the literal meaning of sub is below. On an inheritance tree, that literally describes the relationship between the two classes.


    Depends which way you draw the tree.

    Parent class at the top, child classes at the bottom seems most natural to me, but I work with a guy who pictures it the other way around. I guess maybe he view the base class as the "root" of the tree and the child classes as the "leaves", so it ends up looking like a real tree.
     
    dennis deems
    Ranch Hand
    Posts: 808
    • Mark post as helpful
    • send pies
    • Report post to moderator
    Jeff Verdegan wrote:
    Dennis Deems wrote:
    The literal meaning of super (as well as superior) is above; the literal meaning of sub is below. On an inheritance tree, that literally describes the relationship between the two classes.


    Depends which way you draw the tree.

    Parent class at the top, child classes at the bottom seems most natural to me, but I work with a guy who pictures it the other way around. I guess maybe he view the base class as the "root" of the tree and the child classes as the "leaves", so it ends up looking like a real tree.


    Hm, interesting. The top-down way seems more natural to me, too, and I guess perhaps it's because we're trained to begin reading & writing at the top of a page and work downward. And the only real reason I can think that this is so, is that we would smear the ink on the page if we wrote bottom-to-top.
     
    Winston Gutkowski
    Bartender
    Posts: 10575
    66
    Eclipse IDE Hibernate Ubuntu
    • Mark post as helpful
    • send pies
    • Report post to moderator
    Dennis Deems wrote:The usage that really sets my teeth on edge is using "subclass" as a verb; to say one class "subclasses" another class. Ugly in every way. What's wrong with saying "extends"?

    Tilting at windmills, mate. Just another in the long line of such as: author, incentive, impact and action. I blame it on the Yank hordes myself. Shaw was right: two continents divided by a common tongue.

    Winston
     
    Campbell Ritchie
    Marshal
    Posts: 56584
    172
    • Mark post as helpful
    • send pies
    • Report post to moderator
    Jeff Verdegan wrote: . . . I work with a guy who pictures it the other way around. I guess maybe he view the base class as the "root" of the tree and the child classes as the "leaves", so it ends up looking like a real tree.
    When I had to learn anatomy, I had to learn that this ← is right and this → is left.

    When I moved into computer sciences, I had to learn that this → is right, this ← left, this ↓ up and this ↑ down
     
    Campbell Ritchie
    Marshal
    Posts: 56584
    172
    • Mark post as helpful
    • send pies
    • Report post to moderator
    I think this topic, about nomenclature of classes in Java™ has been done to death. And it wasn’t the original topic.

    Like the newspaper editor, I am going to pull rank and say
    This correspondence now closed.”
    And the correct nomenclature is of course . . .
     
    It is sorta covered in the JavaRanch Style Guide.
      Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!