vendredi 21 octobre 2022

Is there a design pattern for the case of too many injected classes/dependencies?

I have a class that does too many things (many responsibilities). E.g. logging, loading data from various databases, methods that are doing extraneous calculation/processing as well as the main processing method that is this class's responsibility.
I have split the class to multiple classes each doing a specific thing and inject the classes to the original one.
The concern I have is that now I am injecting quite a few classes and I am not sure if that is considered bad design or code smell.
Is there some design pattern, similar as there is e.g. builder pattern for the case of having functions with too many parameters, that addresses the case of having many injected dependencies in a class?

Aucun commentaire:

Enregistrer un commentaire