Page 2 of 2

Re: Multiple inheritance

Posted: Wed Jan 19, 2011 4:04 pm
by N64vSNES
GyroVorbis wrote:Eh, it's just a different style of OO design.

Saying C++ allowing multiple inheritance is "poor design" is really stupid. There are many extremely useful applications for it. The downsides are that it makes things more complex, and there are ambiguities.

Java, C#, and these "single inheritance, multiple interface" OO languages simply favor a different style. They want you to strictly enforce a difference between interface and implementation.

edit: Especially now that I've spent such a considerable amount of time developing with QT... there are some SERIOUSLY fucking convenient/powerful (though questionable) things you can do with multiple inheritance, some casting, and signals and slots.

Here's a snippit from some toolkit code:

Code: Select all

class Entity: public QWidget, public TreeNode, public QGraphicsRectItem, AssetManager {
Poor design? I'll let you decide. The amount of things that QT now handles for me and the thousands of lines of code I can save with this kind of abuse and some clever casting is so fucking worth it.
Daaaaaaaaaaaaaaaaaaaaaaaaaaaaayum.

Re: Multiple inheritance

Posted: Wed Jan 19, 2011 4:23 pm
by Ginto8
GyroVorbis wrote:Eh, it's just a different style of OO design.

Saying C++ allowing multiple inheritance is "poor design" is really stupid. There are many extremely useful applications for it. The downsides are that it makes things more complex, and there are ambiguities.

Java, C#, and these "single inheritance, multiple interface" OO languages simply favor a different style. They want you to strictly enforce a difference between interface and implementation.

edit: Especially now that I've spent such a considerable amount of time developing with QT... there are some SERIOUSLY fucking convenient/powerful (though questionable) things you can do with multiple inheritance, some casting, and signals and slots.

Here's a snippit from some toolkit code:

Code: Select all

class Entity: public QWidget, public TreeNode, public QGraphicsRectItem, AssetManager {
Poor design? I'll let you decide. The amount of things that QT now handles for me and the thousands of lines of code I can save with this kind of abuse and some clever casting is so fucking worth it.
Touche. I guess when you have a good framework it's ok ;) Tho it must be admitted that this is the exception, not the norm, and there are a lot of cases where it just makes things messier rather than easier.

Re: Multiple inheritance

Posted: Fri Jan 21, 2011 2:21 pm
by adikid89
GyroVorbis wrote:

Code: Select all

class Entity: public QWidget, public TreeNode, public QGraphicsRectItem, AssetManager {
*confused* ... so... entities are entire widgets? Why :D ? And what's with the private inheriting of the AssetManager? I'm just confused :( ... care to shed some light on that line of code pls? I can't tell what's going on... and I'm pretty curious, as I've never really encountered a useful application of multiple inheritance.

Re: Multiple inheritance

Posted: Fri Jan 21, 2011 3:30 pm
by dandymcgee
adikid89 wrote:
GyroVorbis wrote:

Code: Select all

class Entity: public QWidget, public TreeNode, public QGraphicsRectItem, AssetManager {
*confused* ... so... entities are entire widgets? Why :D ? And what's with the private inheriting of the AssetManager? I'm just confused :( ... care to shed some light on that line of code pls? I can't tell what's going on... and I'm pretty curious, as I've never really encountered a useful application of multiple inheritance.
My understanding is that Entity inherits QWidget because entities are widgets in the ES Toolkit. I believe they inherit from AssetManager in order to have a pointer to the manager. I'll let Falco confirm and/or explain what is actually going on in more detail.

Re: Multiple inheritance

Posted: Fri Jan 21, 2011 3:33 pm
by Falco Girgis
dandymcgee wrote:
adikid89 wrote:
GyroVorbis wrote:

Code: Select all

class Entity: public QWidget, public TreeNode, public QGraphicsRectItem, AssetManager {
*confused* ... so... entities are entire widgets? Why :D ? And what's with the private inheriting of the AssetManager? I'm just confused :( ... care to shed some light on that line of code pls? I can't tell what's going on... and I'm pretty curious, as I've never really encountered a useful application of multiple inheritance.
My understanding is that Entity inherits QWidget because entities are widgets in the ES Toolkit. I believe they inherit from AssetManager in order to have a pointer to the manager. I'll let Falco confirm and/or explain what is actually going on in more detail.
Yes, and yes. The QGraphicsRectItem is the physically rendered entity.

Re: Multiple inheritance

Posted: Sat Jan 22, 2011 11:43 am
by CC Ricers
Boy that's nuts, even though I can understand how that's implemented. I usually put pointers to managers within the class i.e. composition. At one point I had a base entity class have a manager as a friend class, but the manager would probably have too much power over editing the entities.

Re: Multiple inheritance

Posted: Sat Jan 22, 2011 1:57 pm
by GroundUpEngine
N64vSNES wrote:
GyroVorbis wrote:Eh, it's just a different style of OO design.

Saying C++ allowing multiple inheritance is "poor design" is really stupid. There are many extremely useful applications for it. The downsides are that it makes things more complex, and there are ambiguities.

Java, C#, and these "single inheritance, multiple interface" OO languages simply favor a different style. They want you to strictly enforce a difference between interface and implementation.

edit: Especially now that I've spent such a considerable amount of time developing with QT... there are some SERIOUSLY fucking convenient/powerful (though questionable) things you can do with multiple inheritance, some casting, and signals and slots.

Here's a snippit from some toolkit code:

Code: Select all

class Entity: public QWidget, public TreeNode, public QGraphicsRectItem, AssetManager {
Poor design? I'll let you decide. The amount of things that QT now handles for me and the thousands of lines of code I can save with this kind of abuse and some clever casting is so fucking worth it.
Daaaaaaaaaaaaaaaaaaaaaaaaaaaaayum.
My sentiments exactly! :lol: