Constructor Injection: How many dependencies is too many? [closed]

I would not worry about it.

Instead, I would worry about the class being too complex.

A class with many dependencies that uses them all but has no loops or if statements is fine. In some code I was working on recently there were around 14 dependencies in a class. However, there was only one path through the code and no logical way to group the dependencies into better classes.

A class with a small number of dependencies that contains many branch statements or complex loop conditions should be simplified.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)