Jul-17-2021, 07:42 PM
I'm confused about what you're trying to do then - perhaps code would help. The classes at least must share a common interface - or if not, how does it make sense to substitute one for another?
Sure, you can have a class that is a factory - the idea in general is really just to have a thing that is only responsible for the creation of the objects, so the places that use them don't have that logic. The classic Design Patterns book (by the "Gang of Four") explains the idea in more detail.
Sure, you can have a class that is a factory - the idea in general is really just to have a thing that is only responsible for the creation of the objects, so the places that use them don't have that logic. The classic Design Patterns book (by the "Gang of Four") explains the idea in more detail.