We have a great solution (> 100 projects), and almost every type uses either a service locator (example 1) or our own type dictionary (example 2) to create an instance.
For example, we have:
IQuote quote = Registry.Resolve<IQuote>();
or
IQuote quote = Registry.Find<IQuote>(args);
The second example is disabled in the configuration file to find a specific object to instantiate using reflection.
This complicates life when using the code - because it is not clear which particular type is used, so we have to check the mappings many times, as we try to learn a part of the code. Using the example above, pressing F12 on: quote.DoSomething()
will lead you to an interface definition.
This is also a bit more difficult to implement - we need interfaces + concrete class mappings ++, when the alternative is just 1 class.
Think about it - I don’t know what has ever been "replaced" by another type, therefore, although we implemented IoC, we did not use it, or at least very little.
So, is it really worth it? Have we implemented this / too much? I do not understand something?
source share