Dependency Injection - use with Data Transfer Objects (DTOs)?

前端 未结 3 1275
执念已碎
执念已碎 2020-12-11 04:10

Consider the code below (which has been simplified). I have a service class that returns a list of specific DTO objects that each implement their own specific interface. In

3条回答
  •  天涯浪人
    2020-12-11 05:05

    it doesn't make much sense to me to use any DI for DTOs. I would probably use the Factory Pattern to get DTOs for my model objects.

    DTOs don't need their life cycle managed by the container; I would just new them. Dont over-engineer.

提交回复
热议问题