I was going to point you at the Fowler article.
I really like what you have here. You have some very inventive stuff
going on in your code.
Scala is a different beast than Java and I wonder if the reasons that
the Service Locator pattern was not the "winner" in Java land do not
apply to Scala.
For testing it is very easy to override a def, so if you make a
dependancy a def it should be easy to make a mock for testing. I
guess my point is that is is a perfectly good approach to IOC even if
this is not DI.
> On 26 May 2011 21:37, Alois Cochard <
alois.coch...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
> > Hello all,
>
> > I've just pushed a new examples showing the hierarchical feature, please
> > take a look at this two file:
>
> >
https://github.com/aloiscochard/sdi/blob/master/src/test/scala/sdi/ex...
>
> >
https://github.com/aloiscochard/sdi/blob/master/src/test/scala/sdi/ex...
>
> > You can test it using console mode in SBT.
>
> > So could you please elaborate on the examples I've just gived, why it's not
> > DI ?
>
> > Thanks a lot guys,
>
> > On 26 May 2011 20:13, dholbrook <
davidbholbr...@gmail.com> wrote:
>
> >> I agree that this is a service locator, and not dependency injection.
> >> It violates the Hollywood principle "don't call us, we'll call you".
>
> >> That said there is no reason you couldn't use this to do manual
> >> dependency injection to wire up your object graph. There is no reason
> >> your plain old Scala objects need to know anything about the service
> >> locator.
>
> >> On May 26, 1:52 am, Przemek Pokrywka <
przemyslaw.pokry...@gmail.com>
> >> wrote:
> >> > Hi,
>
> >> > My first impression was "that's nice".
> >> > Unfortunately, it's a service locator (and hardcoded, sadly) and not
> >> > DI actually :(
> >> > Inject method gets imported to domain objects, and AFAIK this is not
> >> > something you can easily swap at runtime?
> >> > Then you don't have the ability to configure objects differently for
> >> > test and for production setups.
> >> > You only centralize your configuration and that is not DI.
>
> >> > Can you fix that? I'd like to be able to use different bindings for
> >> > tests and for production (at least).
>
> >> > regards,
> >> > Przemek
>
> > --
> > *Alois Cochard*
> *Alois Cochard*http://aloiscochard.blogspot.comhttp://
twitter.com/aloiscochard