I have stumbled across the same question while investigating these patterns. I think the major differences can be found between a Service Locator and a Factory (whether it is abstract or not):
Service Locator
- 'Locates' an existing dependency (the service). Although the service may be created during resolution, it is of no consequence to the Client because:
- The Client of the Service Locator does NOT take ownership of the dependency.
Factory
- Creates a new instance of a dependency.
- The Client of the Factory takes ownership of the dependency.
Abstract Factory
- Same as a regular Factory except that different deployments may use different implementations of the Abstract Factory allowing different types to be instantiated in those different deployments (you could even change the implementation of the Abstract Factory at runtime but that's not usually how it's used.)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…