service-locator

When would you use the Common Service Locator ?

I've been looking at the Common Service Locator as a way of abstracting my IoC container but I've been noticing that some people are strongly against this type of this. Do people recommend never using it? Always using it? or sometimes using it? If sometimes, then in what situations would you use it and what situations would you not use ...

Are service locators not just global variables/state?

In order to decouple code you can have service locater's but is this not the same as global variables/state?. I know these often run off interfaces, so you pass in an interface and get a concrete class back but still my question stands. For example: class Something { void DoSomething() { IMyType myType = ServiceLocator.Ge...

Fear of using a Dependency Injection framework

I have been reading up on Dependency Injection frameworks. I really fell in love with the idea of separating the concerns and letting the objects do their core work - which is undoubtedly an excellent and long-standing design principle! However the more I read on DI frameworks, the more I get worried: 1) In the way they "automagically" ...

Using a wcf service registry / service locator from Silverlight

I have a silverlight application that needs to use multiple WCF services. The endpoints (urls) of the services cannot be hardcoded inside the silverlight application or the configuration file. They must be queried from a Service Registry which is itself a WCF service. The problem is that I have to use an async call to query the service ...

StructureMap resolve dependency through injection instead of service location

In my project I register many ISerializers implementations with the assembly scanner. FWIW this is the code that registers my ISerializers Scan(scanner => { scanner.AssemblyContainingType<ISerializer>(); scanner.AddAllTypesOf<ISerializer>().NameBy(type => type.Name); scanner.WithDefaultConventions(); }); Which then correct...

The IOC "child" container / Service Locator

DISCLAIMER: I know there is debate between DI and service locator patterns. I have a question that is intended to avoid the debate. This question is for the service locator fans, who happen to think like Fowler "DI...is hard to understand...on the whole I prefer to avoid it unless I need it." For the purposes of my question, I must av...

Which pattern to use for logging? Dependency Injection or Service Locator?

Consider this scenario. I have some business logic that now and then will be required to write to a log. interface ILogger { void Log(string stuff); } interface IDependency { string GetInfo(); } class MyBusinessObject { private IDependency _dependency; public MyBusinessObject(IDependency dependency) { _de...

For a simple web application, what service locator library you prefer to use?

For a simple application that use asp.net mvc 3 and .net-4, what service locator application is preferred, with performance concern in mind? ...

How can I implement the service locator pattern in Cocoa Touch across multiple projects?

This is a problem which has been bugging me for a while now. I'm still pretty new with some of these patterns so you'll have to forgive me (and correct me) if I use any of the terms incorrectly. My Methodology I've created a game engine. All of the objects in my game engine use inversion of control to get dependencies. These depend...

Is it wrong to call a class a FooFactory if it doesn't *always* create Foo objects?

Is it wrong to call a class a FooFactory if it doesn't always create Foo objects? For example if I have the following interface: public interface IFooFactory { Foo Create(); } and implement it as follows: public class FooFactory : IFooFactory { public IFoo Create() { return ServiceLocator.Current.GetInstance<IFoo>...