The relationship between the complexity of the classes and the size of the IoC constructor did not occur to me before reading this question, but my analysis below shows that having a large number of arguments in the IoC constructor is a smell of code that should be remembered when using IoC. With the goal of sticking to a short list of constructor arguments, you can simply save classes. Following the principles of single responsibility , you will lead you to this goal.
I am working on a system that currently has 122 classes that are created using the Spring.NET framework. All relationships between these classes are set in their constructors. Admittedly, the system has its share of less than perfect code, where I violated several rules. (But hey, our failure is an opportunity to learn!)
The constructors of these classes have a different number of arguments, which I show in the table below.
Number of constructor arguments Number of classes 0 57 1 19 2 25 3 9 4 3 5 1 6 3 7 2 8 2
Classes with zero arguments are either specific strategic classes or classes that respond to events by sending data to external systems.
Those with 5 or 6 arguments are somewhat inelegant and may use some refactoring to simplify them.
Four classes with 7 or 8 arguments are great examples of God's objects . They must be broken, and each of them is already included in the list of problems in the system.
The rest of the classes (from 1 to 4 arguments) (mostly) are simply developed, understandable, and comply with the principle of single responsibility
source share