Is there some design pattern for handling situation where class hierarchy constructors parameters force the most bottom classes to have too many parameters?
Ideally this would be in C++, if language matters. Consider following generic example:
class dependency1;
class dependency2;
class dependency3;
class ClassA
{
public:
ClassA(dependency1* dep1) { }
};
class ClassB : public ClassA
{
public:
ClassB(dependency1* dep1, dependency2* dep2)
: ClassA(dep1){ }
};
class ClassC : public ClassB
{
public:
ClassC(dependency1* dep1, dependency2* dep2, dependency3* dep3)
: ClassB(dep1, dep2) { }
};
Each of the class in hierarchy adds its specific dependency, eventually leading to 3 parameters in last class ctor, even though the 2 parameters are only used to pass to base classes. You can imagine more complicated example with like 11 parameters in the last class...
I understand it might be difficult to answer this in general, but I would like to know how to approach this problem in general.
The only thing close to this I found is using Builder pattern for situation with too many parameters, but it does not seem to fit to this case (or i just don't see how it helps to simplify the class hierarchy).
Feel free to redirect me to duplicate answer, I was not able to find any, but it seems something that should have been already asked.