Skip to main content
31 events
when toggle format what by license comment
Jun 21, 2024 at 11:14 comment added Tigerware Inheritance refers to overriding classes, not interfaces - at least in the statement.
Feb 24, 2021 at 2:19 comment added Craig Hicks It's not just an abstract concept - inheritance is implemented behind the scenes by setting up internal logic and maps so the programmer doesn't have to use a type member and check it in switch statements, if statements, or set up their own maps. Used how and where it should be used that saves a lot of tedious coding and makes the code more clear. If that result is not achieved, it was being used in the wrong way.
Mar 15, 2017 at 13:06 comment added samus @JimmyHoffa This makes sense, and to be honest this is the first time I recall reading it put this way (the contract stuff, Im aware of the many-same concept). I'm going to dig up the textbook and look for the quote that burned this notion of inheritance centric polymorphism into my mind (when I'm digging out my UML texts from storage). It could've been ambiguous, or I could've misinterpreted.
Mar 14, 2017 at 19:09 comment added Jimmy Hoffa @SamusArin Polymorphism is the ability to treat many things like the same thing; you only need consistent contracts across a set of types for all those types to be treated as the same type - treated as the same contract. Inheritance is not about your type contract, inheritance is about taking a type and adding stuff to it, or changing it's internal workings.
Mar 9, 2017 at 12:21 answer added JacquesB timeline score: 20
S Mar 9, 2017 at 10:28 history suggested whalabi CC BY-SA 3.0
Fixed the URL, the post got moved and it redirects to the one I replaced it with (I run that blog)
Mar 9, 2017 at 9:49 review Suggested edits
S Mar 9, 2017 at 10:28
Mar 7, 2017 at 16:02 comment added Andres F. The given example looks like interface inheritance (regardless of the use of the class keyword, in this example there is barely any implementation at all. If you remove the field name, there is none). When people mention the perils of inheritance, they mean implementation inheritance.
Mar 6, 2017 at 18:27 comment added samus @JimmyHoffa What is meant by "Polymorphism is about contractual obligations and 100% removed from inheritance"?
Sep 13, 2016 at 17:17 comment added yegor256 This article may help: yegor256.com/2016/09/13/inheritance-is-procedural.html It explains the difference between implementation inheritance and subtyping and why the former is bad, while the latter is good.
Feb 29, 2016 at 12:00 comment added underscore_d @DavidArno Fair enough. I've no doubt that inheritance is _over_used (as was the subject here), though I've not seen anything bad enough that I'd call as an anti-pattern by default. Either way, my perspective is limited and mostly hinges on C++ requiring inheritance to facilitate polymorphism (at least without some horrible workarounds) - which you might class as a language restraint? Having to use it for that reason does mean I've found a few other cases where it saves time, but those I know can be done other ways. Polymorphism's the only thing that I've not seen a practical alternative basis
Feb 29, 2016 at 8:28 comment added David Arno @underscore_d, no, there's no attempt at trickery; just genuine curiosity. I see both goto and inheritance as sitting in the realm of anti-patterns. I don't see any use for either, save when forced to by language or framework restraints.
Feb 27, 2016 at 8:47 comment added underscore_d @DavidArno Only in extremely edge cases where the alternative - avoiding goto out of puritanism - leads to even more absurd code. I think it's usually a bad idea, but I don't universally demonise it like many commentators do. Anyway, I've never had to use it in my own C or C++. More importantly, it doesn't seem relevant to the actual subject, which is inheritance. What relevance were you trying to invoke, exactly? Hoping I'd say something to flag myself as A Bad Programmer and shore up your rant?
Feb 26, 2016 at 21:49 comment added David Arno @underscore_d Out of curiosity, do you take the view that there are valid (if restrained) uses of goto?
Feb 26, 2016 at 19:49 comment added underscore_d @DavidArno Wow, try calming down and applying a little more reason than emotion to your argument. Do you think you'll win many hearts and minds by coming right out of the gate with a blatantly biased rant and the implication that acknowledging the many (if restrained) valid uses of inheritances disqualifies thousands of people from being "apparently clever programmers"?
Jan 26, 2016 at 10:14 comment added David Arno @immibis, you are half right. "prefer composition" is indeed just a watered down version of what is really meant, as you say. Where you go wrong is in thinking the - well-thought out, derived from evidence and experience - advice to never ever use inheritance is somehow wrong. Inheritance is arguably an even worse feature than goto and global variables. It's not unreasonable to suggest it's the single worse feature ever added to programming languages ever. It depresses me that apparently clever programmers go into denial over this and try to suggest it's valid to use it sometimes.
Nov 6, 2015 at 21:25 comment added Stack Exchange Broke The Law @BilltheLizard I think a lot of the people who say it really do mean to never ever ever use inheritance, but they're wrong.
Sep 14, 2015 at 13:13 history edited user40980 CC BY-SA 3.0
Indent code.
Aug 1, 2014 at 6:31 history protected gnat
Feb 11, 2013 at 22:28 comment added Jimmy Hoffa You want to use composition because a square is just the composition of two triangles, in fact I think all shapes other than ellipse are just compositions of triangles. Polymorphism is about contractual obligations and 100% removed from inheritance. When triangle get's a bunch of oddities added to it because somebody wanted to make it capable of generating pyramids, if you inherit from Triangle you're going to get all of that even though you're never going to generate a 3d pyramid from your hexagon.
Feb 10, 2012 at 7:57 comment added Prashant Cholachagudda I agree with the Bill, I have see using inheritance a common practice in GUI development.
Feb 10, 2012 at 2:57 history edited MustafaM CC BY-SA 3.0
added 1 characters in body
Feb 9, 2012 at 10:43 answer added tdammers timeline score: 33
Feb 9, 2012 at 9:11 vote accept MustafaM
Feb 9, 2012 at 5:19 answer added Philip JF timeline score: 101
Feb 9, 2012 at 3:46 answer added S.Robins timeline score: 71
Feb 9, 2012 at 3:37 history edited user8 CC BY-SA 3.0
remove abusive formatting, fix links, clearer title, clean up flow of question
Feb 9, 2012 at 3:25 comment added vjones You might also want to take a look at programmers.stackexchange.com/questions/65179/…
Feb 9, 2012 at 2:59 answer added Caleb timeline score: 13
Feb 9, 2012 at 2:59 comment added Bill the Lizard No, when people say prefer composition they really mean prefer composition, not never ever ever use inheritance. Your whole question is based on a faulty premise. Use inheritance when it's appropriate.
Feb 9, 2012 at 2:07 history asked MustafaM CC BY-SA 3.0