The no-framework Scala Dependency Injection Framework

Опубликовано: 02 Октябрь 2024
на канале: Parleys
2,796
21

Using a DI framework/container may seem obvious. But when was the last time you considered why do you really need one? After all, "dependency injection" is just a fancy name for passing arguments to a constructor.
In the talk we'll walk through some of the features of DI containers and see if we can replace them with pure Scala code. We'll start with "manual" DI, followed with using MacWire to generate the wiring code for us. Then we'll proceed to a no-framework scopes implementation (e.g. request, session), which are very useful in web applications. Interceptors can be implemented in pure Scala and used declaratively as well!
Finally, we'll see how to use traits to create and compose modules (similar to the module concept known from Guice): the "Thin Cake Pattern".
As MacWire heavily uses macros, as a bonus, I'll explain how Scala Macros work and when they can be useful.
Expect a lot of live-coding and demos!


Author:
Adam Waski
I am one of the co-founders of SoftwareMill, a company specialising in delivering customised software solutions, and daily I mostly code using Scala and Java. I am involved in a number of open-source projects, such as Hibernate Envers, ElasticMQ, Veripacks and MacWire. I have been a speaker at major conferences, such as Devoxx, JavaZone, JFokus or Jazoon.

Apart from writing closed- and open-source software, I am interested in improving the way we use functional and object-oriented programming. When not coding, I enjoy spending time with my family, hiking in the mountains or playing tennis.