Original Post
I'm curious to know if other developers think multiple inheritance is bad practice and if composition should be used instead or if it's a case of "the right tool for the job". The question came about as I recently started work on my entity system again and have found myself with an entity class that has grown inheriting 4 other objects - most times I've only ever needed single inheritance. In my mind this doesn't seem too bad in terms of what is being inherited but I thought I'd just see what others have to say and perhaps improve on my design/skills.
My entity class at its most basic:
Basically an entity contains a list of components and properties, can be serialized and is networked. I suppose I could use composition and have the ComponentContainer and PropertyContainer as members of an Entity instead, but I found it more practical to be able to do the following:
The Serializable and NetworkObject objects allow the Entity to implement it's own logic for file de/serialization , etc and for network de/serialization. A Component object also inherits these objects.
My entity class at its most basic:
class Entity : public ComponentContainer, public PropertyContainer, public Serializable, public NetworkObject
{
public:
};
Basically an entity contains a list of components and properties, can be serialized and is networked. I suppose I could use composition and have the ComponentContainer and PropertyContainer as members of an Entity instead, but I found it more practical to be able to do the following:
entity.AddComponent<MyComponent>();
The Serializable and NetworkObject objects allow the Entity to implement it's own logic for file de/serialization , etc and for network de/serialization. A Component object also inherits these objects.