The multiple-inheritance tag has no usage guidance.
0
votes
3answers
188 views
What to do if I need more than one base class in C#? [closed]
Let's say I have a grid with square fields. For the fields I have an abstract Field class. This class has several subclasses, for example EmptyField or RoadField. Some of these fields can be connected ...
8
votes
4answers
397 views
Parallel hierarchies - partly same, partly different
There are quite a few similar questions out there 1, 2, 3, 4, but non seems exactly the case in this question, nor do the solutions seem optimal.
This is a general OOP question, assuming ...
4
votes
1answer
88 views
Is Python's inheritance an “is-a” style of inheritance or a compositional style?
Given that Python allows for multiple inheritance, what does idiomatic inheritance in Python look like?
In languages with single inheritance, like Java, inheritance would be used when you could say ...
4
votes
1answer
118 views
Using Python's Method Resolution Order for Dependency Injection - is this bad?
I watched Raymond Hettinger's Pycon talk "Super Considered Super" and learned a little bit about Python's MRO (Method Resolution Order) which linearises a classes "parent" classes in a deterministic ...
1
vote
1answer
174 views
Why do you reduce multiple inheritance to the diamond problem?
Whenever I read something like this:
Many programmers exhibit a slight, involuntary shudder whenever
multiple inheritance is mentioned. Ask them to identify the source of
their unease and they ...
17
votes
1answer
2k views
Why not make a language with mixin-only inheritance? [duplicate]
It seems that in all class-based or prototypal OOP languages, mixins are either an afterthought or a secondary feature. However, to me it looks like traditional inheritance is just a specific case of ...
0
votes
3answers
231 views
Multi inheritance in Java
Let's say I've got a generic java class Filter<InputType, OutputType> which receives an input object and transforms it to an output object.
Now I've got two other classes ...
5
votes
1answer
926 views
JavaScript extend vs mixin
After having read Eric Elliott's Fluent JavaScript article, I was and still am toughtful about the way to play with instance prototypes.
On one side, you have the extending inheritance...
var B = ...
0
votes
0answers
477 views
Adding functionality to the activity (inheritance, decoration, strategy … ) or multiple inheritance
I cannot decide what approach should I use in the next situtation.
One activity from my app need to have different functionality, here is the leak of multiple inheritence comes into play.
...
4
votes
2answers
203 views
Is there any harm in having classes made up mostly of inherited classes?
Say I have a few base classes:
HasPosition supplies a 2D location, and methods to "move".
IsDisplayable defines how a class will be displayed in a given graphics library (say, curses), and methods ...
2
votes
1answer
145 views
Language support for (syntactic) delegation in Java
Composition over inheritance is an old trend or even accepted state of the art in object oriented programming. It would be even easier to use in Java, if there were language support for delegation. ...
1
vote
2answers
148 views
The reason for scala not supporting Multiple Inheritance [closed]
I've searched around for a long time now and haven't come up with any official reason why scala doesn't support multiple inheritance. I know traits solve a lot of things, but the developers of C# for ...
24
votes
9answers
4k views
What is different between the internal design of Java and C++ that lets C++ have multiple inheritance? [duplicate]
It's drilled into the newbie Java programmers that Java (pre-Java 8) has no multiple class inheritance, and only multiple interface inheritance, because otherwise you run into diamond inheritance ...
1
vote
4answers
439 views
Implements > extends, but what about variables?
It's preferable to write programs that depend on interfaces rather than on superclasses, but what if you want a class to have certain variables? Sometimes you want a class to implement a certain ...
9
votes
4answers
858 views
Alternatives to multiple inheritance for my architecture (NPCs in a Realtime Strategy game)?
Coding isn't that hard actually. The hard part is to write code that makes sense, is readable and understandable. So I want to get a better developer and create some solid architecture.
So I want to ...
1
vote
3answers
274 views
UML Class Diagram: How can I represent “orthogonal” generalizations (or multi-inheritence)?
I try to represent in a UML Class Diagram the following object and features:
The Object: A System (e.g. an electronic device) that can be of Type A, B or C
If the System is of type A, it has a ...
36
votes
1answer
4k views
How are mixins or traits better than plain multiple inheritance?
C++ has plain multiple inheritance, many language designs forbid it as dangerous. But some languages like Ruby and PHP use strange syntax to do the same thing and call it mixins or traits. I heard ...
6
votes
2answers
3k views
Code re-use in C++, via multiple inheritance or composition? Or…?
I originally asked this question on StackOverflow, but I was directed here, and I think my problem is perhaps as much conceptual as technical, so here goes.
If you’re defining a hierarchy of abstract ...
9
votes
2answers
3k views
How do Traits in Scala avoid the “diamond error”?
(Note: I used 'error' instead of 'problem' in the title for obvious reasons.. ;) ).
I did some basic reading on Traits in Scala. They're similar to Interfaces in Java or C#, but they do allow for ...
-1
votes
1answer
325 views
Size of objects during Multilevel inheritance [closed]
Below is a pseudo declaration for a multilevel inheritance.
Base class ( protected int data)
derived1 : virtual public base ( protected int data1 )
derived2 : virtual public base ( protected int ...
0
votes
1answer
213 views
C# LinqExtensions implement multiple inheritance
According to WikiPedia
"Some languages do not support mixins on the language level, but can easily mimic them by copying methods from one object to another at runtime, thereby "borrowing" the mixin's ...
88
votes
9answers
14k views
Is there any “real” reason multiple inheritance is hated?
I've always liked the idea of having multiple inheritance supported in a language. Most often though it's intentionally forgone, and the supposed "replacement" is interfaces. Interfaces simply do ...
2
votes
1answer
5k views
Adding base-class (inherited) functionality to classes that you don't control
I have a set of classes from a 3rd party library. These classes use an inheritance structure to share logic. I would like to add a layer of abstraction in the middle of their inheritance tree to add ...
6
votes
1answer
300 views
Term for a Class with Multiple Interfaces
Say I have a class that implements multiple interfaces. I pass the same instance around using a different interface, depending on what the consumer is interested in.
I am trying to remember what this ...
4
votes
2answers
2k views
Python multiple inheritance or decorators for composable behaviours
I recently discovered (or rather realised how to use) Python's multiple inheritance, and am afraid I'm now using it in cases where it's not a good fit. I want to have some starting data source ...
12
votes
2answers
4k views
How does C++ handle multiple inheritance with a shared common ancestor?
I'm not a C++ guy, but I'm forced to think about this. Why is multiple inheritance possible in C++, but not in C#? (I know of the diamond problem, but that's not what I'm asking here). How does C++ ...
3
votes
1answer
845 views
Can Objective C categories serve the same purpose as Traits do in Scala?
The statement of the question seems little abstract to me, so please read the details below.
Since the time when C++ was the first choice Object Oriented Language for almost anything, we had a big ...
15
votes
5answers
5k views
Proper workaround for multiple inheritence in Java (Android)
I have a conceptual problem with a proper implementation of code which seems require multiple inheritance, that would not be a problem in many OO languages, but as the project is for Android, there ...
17
votes
6answers
2k views
Does multiple inheritance violate Single Responsibility Principle?
If you have a class which inherits from two distinct classes, does not this mean that your subclass automatically does (at least) 2 things, one from each superclass?
I believe there is no difference ...
1
vote
2answers
1k views
Replacing Multiple Inhertance with delegation
I was going through "Object Oriented Modelling and Design" by James Rumbaugh et al and it said that in languages where multiple inheritance is not supported like Java three mechanisms can be used as ...
6
votes
1answer
3k views
Rails - to use STI or not…that is the question
Six months ago, I asked a question about modeling data for my app, and received some advice pointing me towards STI (see Rails data model - best practices question for the details).
I played around ...
3
votes
2answers
4k views
What are the pros and cons of multiple inheritance? [closed]
What are the consequences of allowing multiple inheritance in a programming language? Why does multiple inheritance tend to violate the very essence of OOP? Is that what differentiates a pure OOP ...
0
votes
1answer
288 views
How to layout class definition when inheriting from multiple interfaces
Given two interface definitions ...
IOmniWorkItem = interface ['{3CE2762F-B7A3-4490-BF22-2109C042EAD1}']
function GetData: TOmniValue;
function GetResult: TOmniValue;
function GetUniqueID: ...
11
votes
7answers
2k views
Multiple inheritance use cases
Java omits multiple inheritance on the grounds that it obviates the design goal of keeping the language simple.
I wonder if Java (with its eco-system) is really "simple". Python is not complex and ...