What design pattern should I use for specific multiple inheritance?
DynamicSquid

Let's say I have an interface called Squid.

And we have a bunch of different types of squids:

Here's everything a squid can be:

aquaticland
basicbasic-aquaticbasic-land
advancedadvanced-aquaticadvanced-land

How would I go about create an instance of a squid? Should I go about creating 4 classes BasicAquaticSquid, BasicLandSquid, AdvancedAquaticSquid, AdvancedLandSquid like this:

I think that's called the Abstract Factory method? It seems very tedious though. Any better way of doing so?

Thanks

You are viewing a single comment. View All
Answered by xxpertHacker [earned 5 cycles]
View Answer
xxpertHacker

@DynamicSquid We can both agree on what to choose from those questions I raised, and Rust made the right choices.

Simply think of the restrictions like you think of what you can do in C/C++ on a pointer.

Let's start, what is a pointer?
Computers only understand numbers, a pointer is a literal integer, yet... in a way, it's not.

It is an integer, yet it simply is used to load and store memory at the specific point that it "points" to.
Why do I bring this idea up at all?
Because they are an abstract idea, but they have restrictions.

Does that seem like a weird restriction? Hopefully not. Yet it makes perfect sense to restrict what can be done in some cases, yet most of the time, C++ just lets you do whatever you want, whether or not it makes sense at all.