CID interview question

How would you implement Dependency Injection?

Interview Answer

Anonymous

27 Nov 2017

I would create a static class with a dictionary inside. Dictionary should consist of type and object itself. That would be singleton. For other objects it could be created through factory methods. So maybe it would make sense to also provide a method to register a type with factory action callback. However, I believe .NET has wonderful dependency injection frameworks (like Ninject or Autofac or the one provided by Microsoft in dotnet core).