Skip to main content
1 of 3
ipavlu
  • 129
  • 6

Dependency Injection - number of injected parameters smells

I was tonight thinking what it tells about design and architecture of classes with many injected objects. I am taking into consideration setter and constructor injection specifically.

Setter injection proponents always argument with constructor injection complexity in opposition to setter simplicity especially in cases where number of parameters in constructor grow, but that is different topic.

I would think, that large number of injected parts suggest breach of single responsibility of the object. There could be special snow flakes, but in general good metric I think.

Now how to fight it especially in cases where vertical depth of constructors is bigger than lets say 3?

I am thinking about some guidance\rules to fight these cases.

ipavlu
  • 129
  • 6