I study the code of some different libraries and notice that some of them will provide equivalent general and non-general functions in one class.
One example is the IServiceLocator interface of a common project maintenance locator :
public interface IServiceLocator
{
object GetInstance(Type serviceType);
object GetInstance(Type serviceType, string key);
IEnumerable<object> GetAllInstances(Type serviceType);
TService GetInstance<TService>();
TService GetInstance<TService>(string key);
IEnumerable<TService> GetAllInstances<TService>();
}
The impression I get is that it maximizes availability, possibly from COM. In the absence of these problems, this seems like redundant code. Is there something I am missing?
source
share