Framework-less Scala Dependency Injection frameworks by Adam Warski @adamwarski

Using a DI framework/container may seem obvious, especially in web development. But *why* do you really need one? After all, "dependency injection" is just a fancy name for passing arguments to a constructor.

In the *live-coding-only* talk (no slides!) we'll walk through some of the features of DI containers and see if we can replace (and improve!) them with pure, type-safe Scala code. We'll start with "manual" DI, followed by using MacWire to generate the wiring code for us. With one simple `wire[]` macro, we can save a lot of typing and still use only Scala language features for creating the object graph at runtime.

Having solved the basic problem, we’ll proceed other features of DI containers and web frameworks: scopes and interceptors. We’ll see how to implement an interceptor, and that it’s far easier than it may seem.

Finally, we'll see what "Thin Cake Pattern” is, and how to use traits to create and compose modules (similar to the module concept known from Guice, but better).

As a bonus - I’ll have some not-only-Scala-related stickers.

Join or login to comment.

  • Dustin W.

    Here is the video of Tom Switzer's talk on Framian:
    https://www.youtube.com/watch?v=...­

    Getting Alex's ready...

    1 · October 9

    • Anne M.

      Yes, but it's nice to hear about links, at least imho :). It was this; Two Talk October: Alexandre Bertails and Tom Switzer - ny-scala (New York, NY) - Meetup
      http://www.meetup.com...­

      October 9

    • Dustin W.

      Haha, I wondered where this comment went. Loaded up the wrong meeting from browser history

      1 · October 9

  • Stephen C.

    See https://bazaar.launchpad.net/~sc...­ for another frameworkless (and amusing) approach to DI, via shapeless.

    September 8

    • Adam W.

      Ah shapeless - that must be interesting :) Any chances for a version with comments what's happening there?

      September 9

  • Adam W.

    Thanks for coming and for having me at the meetup! I hope you enjoyed the presentation. If you would have any questions regarding DI in Scala & MacWire (or stickers / CodeBrag / ScalaTimes / SoftwareMill consulting), just mail me: adam at warski dot org

    I'm also in NY today if you'd like to chat personally.

    I wrote a guide to DI in Scala using pure Scala+MacWire: http://di-in-scala.github.io/­. The examples are railroad-based, instead of restaurant-based, otherwise the material is similar to what was in the presentation.

    Thanks again,
    Adam

    2 · September 9

  • Adam M.

    Any chance there's room for folks on the waiting list?

    September 8

    • Nathan H.

      Sorry, we can only accommodate 100

      September 8

  • Shun "David" S.

    Hello, do you plan to start the talk at 7:00pm?

    September 8

    • Adam W.

      Yes, around that time, once all the setup is done. Unless the organisers are planning some extras :)

      1 · September 8

    • Nathan H.

      There will be no surprise talks this evening. We'll start a few minutes after 7, or whenever I can get everyone to sit down. ;)

      2 · September 8

  • Muhammad A.

    Would the pace of session be beginner-friendly?

    September 8

    • Adam W.

      Definitely. And in case something is not clear, just ask

      September 8

  • Anne M.

    FYI, Adam's related blogpost; http://www.warski.org/blog/2014...­
    Using Scala traits as modules, or the “Thin Cake” Pattern By Adam Warski 25 February, 2014

    1 · September 8

People in this
Meetup are also in:

Create your own Meetup Group

Get started Learn more
Bill

I started the group because there wasn't any other type of group like this. I've met some great folks in the group who have become close friends and have also met some amazing business owners.

Bill, started New York City Gay Craft Beer Lovers

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy