What's the difference between the Service Locator and the Factory Design pattern?
问题 I'm using unity and I'm creating a class that wrapps it and I dont' know how to call it, service locator or factory, both encapsulate the creation of the objects, so.... what's the difference? 回答1: A factory creates objects for you, when requested. Service locator returns objects that may already exist, that is services that may already exist somewhere for you. Just think about the meaning of the names: Factory: is a place where objects are created. Service: is something that can do something