Talk:Inheritance (computer science)

This article has been kept following this VFD debate. Note that it has been suggested that another article be merged with this one. Sjakkalle (Check!)  09:44, 11 August 2005 (UTC)

See also: Talk:Inheritance_(object-oriented_programming)

I commented out reference to CSS as example of inheritance because CSS does not behave with inheritance; it is not possible to actually inherit from a class and modify it. Instead you get to override the prior definition.


 * I disagree. While it's not actually called inheritance, it does behave similarly. One of the fundamental aspects of the design of CSS is that properties can "cascade" - some properties can be overridden, while others will "inherit" from previously defined classes. -- Wapcaplet 03:25, 26 Oct 2003 (UTC)

I'm not sure we are in full disagreement. CSS definitely cascades but doesn't really inherit. I almost removed the change because I realized it had been a while (a few months) since I had actually cursed the design of CSS while trying to get true inheritance from it, so I couldn't remember the specifics well enough to as clearly detail why it isn't. Maybe I'll go try and do some CSS again so I can remember why I hate it so much (and wish it were more object-oriented.)  MikeSchinkel 03:36, 26 Oct 2003 (UTC)


 * I'm not sure what you mean by "true" inheritance; it seems to me that there is definite inheritance going on, though. It is even explicitly mentioned in the specification. It's not the same kind of inheritance that is present in object-oriented programming, but that's part of the reason we have separate articles for the two concepts (after much disagreement on the topic!) I like CSS :-) -- Wapcaplet 18:27, 26 Oct 2003 (UTC)

Tell ya what, next time I work with CSS and run into the reasons for my dislike and belief it isn't object oriented, I'll rush here and give a full narrative. Right now I just can't remember. BTW, its not that I prefer CSS over nothing, just that I dislike it more for what it is not than for what it is. MikeSchinkel 23:55, 29 Oct 2003 (UTC)


 * Oh, it's definitely not object-oriented. It's not supposed to be; it's not even a programming language. But I do think it has inheritance (and the W3C seems to think so too). -- Wapcaplet 21:19, 30 Oct 2003 (UTC)

Well, the W3C standard calls it inheritance and properties are (loosely:)) inherited by child elements, so it is part of the computer science coverage of the topic. Obviously, it's not a very pure representation of what I'm thinking of when writng C++.:) But this article is broader than just OOP... that's why it's at computer science instead of confined only to OOP's view of the concept. OOP can be purist about it (and maybe should be), but that's not the right viewpoint for a general overview of the whole concept. Mike, please let rip here on the compare and contrast - that'll produce some good coverage of the similarities and differences in the use of inheritance in CS.JamesDay 23:26, 30 Oct 2003 (UTC)


 * Wow. I think I stepped in it when I made the prior statement! Haven't had time till now to get back to this, but fortunately I've had a chance to work with CSS in the mean time so now I can say why I don't view it as supporting "inheritance" although clearly someone at the W3C thought so! (what were they thinking?!? :)


 * Seriously, this really begs the question of what is "inheritance," as the inheritance defined by the author of the W3C CSS spec is definitely not the same type of inheritance that you find in an OOP programming language. Let me try to quantify this statement: Let's take the intro definition for inheritance from the current state our entry: "In computer science, inheritance creates an "is-a" relationship between data structures."  Assuming that is correct (and our discussion begs that question too), then I contend CSS does not support inheritance after all, regardless of what says the W3C.


 * First, let's assume we think of a generic HTML "element" as an object as it is represented for DHTML. Each element has attributes (properties) such as "font", "border", etc. Each named element (i.e. "&lt;p&gt;", "&lt;td&gt;", etc.) does "inherit" those attributes though here we are talking about static HTML and not user-definable CSS.


 * But the statement from W3C says an &lt;em&gt; would "inherit" the color of an &lt;h1&gt; in which it is embedded. This is at best a form of what I'd call "attribute-value inheritance", not the "is-a" inheritance as currently defined in this entry.  After all, is an &lt;em&gt; a &lt;h1&gt;?  Of course not.  They are both "elements," but they are only siblings at best.


 * So it seems to me if we want to incorporate CSS as an example of inheritance, we must first completely revamp the definition of inheritance and then provide explicit descriptions of the varying types or styles of inheritance. (If I had the time to do this, I would, but I'm really behind the 8 ball at work right now.) Of course I'm sure it will create a few orders of magnitude more discussion and debate because to perfect the concept at a much higher abstract level.


 * So, back to my assertion that CSS does not offer inheritance. Clearly the author of the CSS spec for the W3C thinks it does, however, I will further assert the author was probably being convenient when choosing that description and was not thinking about how it would be used if inheritence were to be defined in a rigorous manner (I will not fault for this; it is impossible to be rigorous about every single nuance in writing if if is important to get the work published in one's lifetime.  I know, I wrote a 1000 page book once, and it took *far* too long for me to finish it. :-)


 * IMO the "inheritance" referenced by the CSS spec author is a more colloquial form than the rigorous definition use by OOP. Put another way, the CSS form is easy to understand w/o any computer science training (i.e. " Look Ginny Mae, he done got your eyes, that new little boy of yours has! ") However, IMO again the "is-a" relationship takes a deeper understand of computer science concepts and needs to be specifically studied to be understood by most people. I would also assume people would more often seek out the complex usage of a concept than the simpler one, so I would assume having OOPs definition would be of more importance than in trying to help someone understand the analogies of biological inheritance.  Again, its my opinion.


 * As such, I assert including CSS as an example for computer science inheritance inadvertently obscures the meaning used in OOP and makes it far harder for someone to understand than if the explanation was clear, succinct, and had not comflicting examples. So I would propose we either need to greatly expand the definition to explicitly define the various types of inheritance with relevent examples in each area, or we omit any reference to CSS and similar as providing inhertance. I hope that sits well with everyone?


 * In closing, I'll say that I make these statements based on my experience over the past 20 years in software development and instruction of software developers, but I will also say that there are orders of magnitude more issues in computer science about which I do not know than they are things about which I do. It may be my explanations are niave based on significant lack of knowledge and such my arguments may not hold water. For example, maybe there is an even more important form of inheritance in computer science for which I am unaware or have forgotten to consider.  So I am clearly open to changing my mind, but only based on verifiable facts provided by someone with a lucidly explained and cogent argument. :-)  Thanks for taking the time to read my rant! MikeSchinkel 08:29, 9 Nov 2003 (UTC)

This is something of a can of worms that you may be onto here! I'd invite you to refer to several months' worth of discussion on Talk:Inheritance (object-oriented programming), if you haven't already. It's surprising how emotionally entangled one can get with the seemingly simple issue of naming an article.

I do agree that whatever is happening in CSS is certainly not any kind of "is-a" relationship, and I would prefer not to have any object-oriented principles implied in the current article, since there is already Inheritance (object-oriented programming) for covering that. Inheritance (computer science) is in its infancy, and needs a ton of work that I am probably not qualified to do, so please feel free to improve it.

As you might gather from the other discussions, there is some disagreement about whether inheritance makes any sense outside of an OOP context. I think that there are some areas of computer science that have an inheritance concept, yet have nothing to do with object-oriented programming. CSS is one of them; it's open for debate whether it should really be called inheritance, but the W3C refers to it as such, so I think there should at least be a mention of it. Of course, we shouldn't limit it to CSS; if you can think of other CS-related circumstances, outside of OOP, in which some form of inheritance is used, those would be great to have too! -- Wapcaplet 18:17, 9 Nov 2003 (UTC)

Mike, thanks, that's just the sort of thing I thought that you'd end up writing (because it's the sort of thing I'd be writing if I was thinking in C++ programmer mode:)). It's part of why I didn't want the (OOP) version to be the (CS) article. The Wikipedia is descriptive, not prescriptive, so we have to describe all of the semi-common uses of the term. Hence, word processing as an easy to understand introduction for non-programmers, CSS as a really common use and OOP as another very common use. The article needs to do as you remarked: either adjust the definition to include all of the uses or have multiple definitions to cover each class of meaning. Then it gets to compare and contrast and refer to the topic-specific articles for more details of how those topics define and use the term. At that point, we'll have some really comprehensive coverage of what inheritance can mean in the field. And Inheritance (OOP) can be really purist about what it means by inheritance, as can CSS be about its meaning.:) JamesDay 05:45, 10 Nov 2003 (UTC)

[This comment is part of the Controversial Articles list --] References (contain links outside Wikipedia): CLU -- Smalltalk -- Simula67 [Here is some history of the concept] --
 * Historically, this was a reaction to Pascal (late 1960s, early 1970s), which did structured programming. Pascal was a flow-of-control kind of language, as is C (1972). The degree of detail required for implementation overwhelmed the attention. Smalltalk (first implemented in Simula67) allowed for the concept of inheritance. Liskov admits, in CLU (mid 1970s), that even her concept of data abstraction did not brook inheritance. It took Stroustrup's C with Classes (early 1980s) to open people's eyes to the concept of implementing data types which is immanent in the C typedef.
 * Stroustrup used his experience with Simula67 to design the language, now known as C++ in the 1980s. During the period of implementation, great excitement about the power of the inheritance concept led Stroustrup to add in multiple inheritance to the syntax of the C++ language. However, in such cases, as programmed classes instantiated objects, the data structures of such programs sometimes contained cyclical definitions, and poor performance. This led to the bumper sticker slogan Multiple inheritance is the GO-TO of the 1990s.
 * As C++ grew in popularity, Java arose 1996 and disallowed the multiple inheritance construct. Instead Java provided for simulation of multiple inheritance, by including the interface keyword. This allows classes to implement an abstract class or interface. This style of programming is called component-based programming, and is currently causing great excitement in the computer science community.
 * Because neither C nor C++ are proprietary languages, compiler vendors like Microsoft found no problem embracing and extending the language(s) with concepts like MFC (Microsoft Foundation Classes) for Windows-based programs.
 * But in reaction to possible loss of control (and revenue), Sun Microsystems withdrew Java from the standards process. In the 2000s Sun and Microsoft are engaged in ontological warfare over who will inherit the programming language market. See .NET versus J2EE component libraries.

[Here is some content]

Inheritance is expressed with the extends keyword in Java, which is an is-a relationship, or by the : notation in C++. The inheritance concept reifies the is-a relationship. Thus the proposition "Socrates is a Man" states that 169.207.85.65 13:24, 2 Nov 2003 (UTC)
 * "Socrates extends Man" in Java-style pseudocode, or
 * "Socrates : Man" in C++-style pseudocode.
 * [Socrates]->[Man] would be a UML-style graphic notation; the arrowhead is a white triangle, both classes in brackets would be in graphical boxes.
 * Sowa's conceptual graph would put the 'is-a' in a circle between Socrates and Man.

It seems to me that this article is heading straight down the road of "Inheritance only exists in object-oriented programming." The opening sentence even states that inheritance creates an "is-a" relationship. There has been a lot of discussion about whether this article should exist; the only reasonable justification for its existence is the notion that inheritance makes sense outside the context of OOP, so I think we should try to make this article about inheritance that occurs in other ways in computer science. -- Wapcaplet 14:52, 5 Jan 2004 (UTC)

OK, I'm gonna dive in and do a rewrite. No offense to those who have contributed to the current version, but as it stands it's strongly structured towards the object-oriented programming concept of inheritance; I think this article should be relatively short, and be something more like a disambiguation page (since we already have Inheritance (object-oriented programming) and Inheritance (genetic algorithm)) and brief discussion of a few of the potential alternate meanings for "inheritance" in broadly computer-science-related areas, such as CSS, word processor styles, and implementation of inheritance concepts in non-OO languages. Some mention also of the disagreement over what is "true" inheritance and what isn't (some believe that inheritance makes no sense outside of OOP, in which case this article shouldn't even exist; some, like me, believe that we should at least mention the cases where the word "inheritance" is used even though it isn't "true inheritance" of whatever kind). Here goes... -- Wapcaplet 19:35, 12 Feb 2004 (UTC)

Missing definition of is-a
Attempts of reading on the topic of "is-a" leads by way of redirects to here where the expression is not even mentioned once in the article. I wish people were not that trigger happy about redirects without doing the actual works of merging the topics and making sure there is no loss on the way.

In fact as the original topic stands it is more enlightening than the redirects it was replaced by.


 * I too would like to have at least a short explanation of is a. --Abdull 17:22, 22 May 2006 (UTC)

Relationship between inheritance and polymorphism
Inheritance and polymorphism are not "dual views" of the same thing. I would rather say that they partially overlap, with the concept of subtyping polymorphism. Also this "dual view" stuff is explained quite poorly IMHO, in both articles. Having said that, I just discovered that there are two inheritance pages (OOP and Computer science) and frankly I lost interest. Good luck.PizzaMargherita 22:04, 25 October 2005 (UTC)

Prototype-based programming
The introduction currently reads
 * In object-oriented programming, inheritance is a way to form new classes (instances of which are called objects) using classes that have already been defined.

However, as far as I understand, the term inheritance is also used within the framework of prototype-based programming where classes do not exist as independent entities. I think this usage should be reflected in the definition. &mdash; Tobias Bergemann 12:04, 6 June 2006 (UTC)

Inheritance (programming)
Inheritance (programming) currently redirects to class (computer science), and does so since its creation. Is there a specific reason for this? Otherwise, I would turn Inheritance (programming) into a redirect for Inheritance (computer science). &mdash;Tobias Bergemann 12:08, 6 June 2006 (UTC)


 * This is a good idea.


 * Shawnk talk—-Shawn wiki 13:47, 5 August 2006 (UTC)


 * Done. -- Shadowlynk 05:06, 15 September 2006 (UTC)

Probable grammatical error
From the second paragraph: "Categorization is a powerful mechanism number of information processing...". This makes no sense to me, so there's an error in there somewhere. As I'm not quite sure what the writer was trying to say, rather than correcting it I'll just make a note here so that someone else can correct it.

Role
In the Roles and inheritance section, what is meant with role (computer science)? --Abdull (talk) 15:53, 8 February 2008 (UTC)

Examples needed
Hello there. I suppose having examples with the text would certainly reinforce the ideas very nicely. This one seems to miss examples as is common with other computer science articles.Aijazbaig1 (talk) 10:00, 15 July 2008 (UTC) Aijaz

TYPES OF INHERITNCE
1.Single inheritance 2.Multiple inheritance 3.Multilevel inheritance 4.Hybrid inheritance 5.Hirarchical inheritance —Preceding unsigned comment added by 122.168.54.186 (talk) 13:21, 25 July 2008 (UTC)