I'm working on a app where DI was avoided to improve performance. The service dependency is implemented as a static class and referenced directly in the calling class. This is presenting the typical challenges for testing since it's not possible in inject a stub for this service.
My first thought is to setup a regular class and interface, put it into the container as a singleton, and then inject it into the calling class constructor. This API app is very performance critical, so the design choices cannot add any extra milliseconds to the response time.
Is it possible to use DI without adding some performance overhead? If not, is there another design pattern I can use to maintain performance but improve the testability of the class at the same time?
Aucun commentaire:
Enregistrer un commentaire