On Jun 16, 11:34 am, Jules <julesjac...@gmail.com> wrote:
> I still don't know what dependency injection means exactly. The
> examples I've seen that are said to use dependency injection can be
> solved by using first class functions. Are first class functions what
> you want?

Dependecy injection is nothing more than the difference between this:

public class Bosh {
  private final Dependecy dep = new DependencyImpl();
}

and this:

public class Bosh {
  private final Dependecy dep;
  public Bosh(Dependency dep) { this.dep = dep; }
}

In both cases Bosh needs a Dependency. It depends on having one. In
the first  case the actual implementation is hard coded. In the second
the implementation is provided, or to put it another way, the
dependency is injected.

Higher order functions obviously fit the bill. Map depends on a
mapping function, which you have to inject as a parameter when you
call it.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to