How to avoid Dependency Injection constructor madness?

前端 未结 9 1841
别跟我提以往
别跟我提以往 2020-11-22 03:59

I find that my constructors are starting to look like this:

public MyClass(Container con, SomeClass1 obj1, SomeClass2, obj2.... )

with ever

9条回答
  •  攒了一身酷
    2020-11-22 04:40

    I don't think your class constructors should have a reference to your IOC container period. This represents an unnecessary dependency between your class and the container (the type of dependency IOC is trying to avoid!).

提交回复
热议问题