Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How would one do dependency injection in scala?

I'm still at the beginning in learning scala in addition to java and i didn't get it how is one supposed to do DI there? can or should i use an existing DI library, should it be done manually or is there another way?

like image 210
Fabian Avatar asked Apr 01 '10 21:04

Fabian


People also ask

What is dependency injection in Scala?

Dependency injection is a widely used design pattern that helps separate your components' behaviour from dependency resolution. Play supports both runtime dependency injection based on JSR 330 (described in this page) and compile time dependency injection in Scala.

How do you perform a dependency injection?

Types of Dependency Injection The injector class injects dependencies broadly in three ways: through a constructor, through a property, or through a method. Constructor Injection: In the constructor injection, the injector supplies the service (dependency) through the client class constructor.

What is dependency injection give example?

Dependency injection (DI) is a technique widely used in programming and well suited to Android development. By following the principles of DI, you lay the groundwork for good app architecture. Implementing dependency injection provides you with the following advantages: Reusability of code. Ease of refactoring.


1 Answers

Standard Java DI frameworks will usually work with Scala, but you can also use language constructs to achieve the same effect without external dependencies.

like image 200
Dan Story Avatar answered Sep 18 '22 12:09

Dan Story