Skip to main content

Questions tagged [multiple-inheritance]

Filter by
Sorted by
Tagged with
2 votes
1 answer
144 views

In my project I have several "basic" interfaces whose behavior is fixed, i.e. the default implementation will always be good for every puropse. So I defined them as concrete classes with ...
Nicola Mori's user avatar
18 votes
8 answers
14k views

I know there have been many post about diamond problem, one of it: Why do you reduce multiple inheritance to the diamond problem?. But I'm not asking what it is or what is the solution of the problem. ...
wcminipgasker2023's user avatar
0 votes
0 answers
589 views

Because I have multiple entities with unique fields, I need multiple repositories for each one even though each Entity will be handled exactly the same. What is the best way to handle these separate ...
dbrewster's user avatar
  • 139
-1 votes
1 answer
878 views

C++ and Python are the only two languages I know supporting multiple Inheritance. Other object oriented languages I have seen like Java and Ruby do not support multiple inheritance. Even the front-end ...
Arunabh's user avatar
0 votes
1 answer
72 views

I want to model a machine with a class machine. By the way the architecture of the project has been built, the module that defines each machine is its own directory. So in directory manufacturer/...
TeXtnik's user avatar
  • 101
0 votes
1 answer
87 views

Lets imagine some vendor code that we want to extend on our project level protected function getDefaultFormClasses() { return [ new FormClassA(), new FormClassB(), new ...
Jim Panse's user avatar
  • 408
2 votes
1 answer
318 views

I have a lot of classes that are just a CRUD interface for microservices. They only have a param for the endpoint and some of the methods get_list / get_item / create / update / delete / activate / ...
xpy's user avatar
  • 129
6 votes
3 answers
9k views

I am writing a Python framework. In order to ensure a class has some properties, I make base "interface" classes like: class BananaContainer: def __init__(self): self._bananas = [] @...
mguijarr's user avatar
  • 226
2 votes
1 answer
268 views

I want to use a physics engine (like bullet or PhysX) in my program, however I want to hide the actual physics engine from it, so I can easily swap it out with another during run-time (e.g. switch ...
user225183's user avatar
2 votes
1 answer
368 views

I'm writing a program that will interface with an external device. It will support numerous devices that may use different communication interfaces like USB, serial, etc. This is what I have so far: ...
John O'brien's user avatar
2 votes
4 answers
5k views

In my previous question, it was highlight that implementations of C++ such as GCC must store a vtable pointer in every copy of a class for each parent class which has a virtual function. So a class ...
Clinton's user avatar
  • 1,093
18 votes
2 answers
19k views

Is it a code smell if the methods in my trait refer to parent::methods or to methods that are assumed to be in the utilising class? A random (senseless) example trait foo { public function bar() ...
Kamafeather's user avatar
0 votes
3 answers
157 views

I am currently creating Excel import modules for some complex data. I didn't plan it well and I have met code reuse issues. I have made first modules and I realized that next modules will need some ...
helvy91's user avatar
  • 29
1 vote
1 answer
115 views

How do you handle fat interfaces? Here is an example: public class TSP { public AddEmployeeContribution(...) {...} public AddMatchingContribution(...) {...} public CalculateTotal() {...} ...
keelerjr12's user avatar
  • 1,273
-1 votes
1 answer
157 views

I have a statement. I know the ups and downs of both Composition and Inheritance, but I am unable to realize that what would be the best option the given scenario. SCENARIO: A Software company is ...
Khubaib Khawar's user avatar
6 votes
1 answer
2k views

I am trying to implement the following pattern in a Cache layer. I'm splitting the implementation of possible Cache methods such as getUsers() in UserCache Class, getLikes() in PostsCache class. But ...
Magesh Kumaar's user avatar
3 votes
2 answers
737 views

I have the following tree currently to be implemented in Java. My problems are the following: How can I go about addressing the fact Admin needs to have all tier 4 logic from both branches of the ...
Leon's user avatar
  • 207
-2 votes
2 answers
6k views

What is the meaning of separating interface from implementation in C++? And also what is implied by interface and implementation?
Abhyuday Singh's user avatar
1 vote
2 answers
6k views

In some languages (e.g. C#) a class can only ever have 1 base class which seems like a problem for what I'm trying to do. I will give you an example of what i'm trying to do, hopefully this will make ...
Vincent's user avatar
  • 383
1 vote
4 answers
3k views

I am currently perusing through Jdk 8 and I came across the feature where you have multiple interfaces that overlap with the same method signature for a default method, the compiler will throw an ...
SteelToe's user avatar
  • 1,599
0 votes
3 answers
19k views

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 ...
gartenriese's user avatar
13 votes
4 answers
4k views

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 polymorphism,...
Izhaki's user avatar
  • 391
9 votes
2 answers
939 views

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 ...
Iain's user avatar
  • 450
11 votes
1 answer
2k views

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 ...
Iain's user avatar
  • 450
4 votes
1 answer
2k views

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 ...
Valentin Tihomirov's user avatar
20 votes
1 answer
3k views

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 ...
Den's user avatar
  • 4,887
0 votes
3 answers
2k views

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 (NoInputFilter<...
Obenland's user avatar
  • 201
5 votes
1 answer
3k views

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 = ...
Tot's user avatar
  • 147
4 votes
2 answers
326 views

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 to ...
Carcigenicate's user avatar
3 votes
1 answer
322 views

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. ...
Harald's user avatar
  • 181
0 votes
2 answers
668 views

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 ...
voluminat0's user avatar
26 votes
9 answers
4k views

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 ...
DVK's user avatar
  • 3,576
3 votes
4 answers
6k views

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 ...
Dylan Meeus's user avatar
11 votes
4 answers
4k views

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 ...
Brettetete's user avatar
1 vote
3 answers
1k views

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 ...
Renaud Tarnec's user avatar
66 votes
1 answer
13k views

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 ...
Gherman's user avatar
  • 945
10 votes
2 answers
12k views

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 ...
Leo's user avatar
  • 203
20 votes
2 answers
20k views

(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 ...
Aviv Cohn's user avatar
  • 21.6k
-1 votes
1 answer
1k views

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 ...
Haswell's user avatar
  • 119
0 votes
1 answer
498 views

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 ...
Andyz Smith's user avatar
155 votes
9 answers
45k views

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 ...
Panzercrisis's user avatar
  • 3,223
4 votes
1 answer
12k views

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 ...
Jesse Webb's user avatar
7 votes
1 answer
488 views

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 ...
Travis Parks's user avatar
  • 2,583
5 votes
2 answers
6k views

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 (...
Matti Lyra's user avatar
13 votes
2 answers
8k views

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++ ...
Sandeep's user avatar
  • 241
3 votes
1 answer
1k views

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 ...
Amogh Talpallikar's user avatar
16 votes
5 answers
11k views

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 ...
Stan's user avatar
  • 271
23 votes
7 answers
4k views

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 ...
Random42's user avatar
  • 10.5k
2 votes
2 answers
3k views

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 ...
user5507's user avatar
  • 243
8 votes
1 answer
6k views

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 ...
Jim's user avatar
  • 1,997