Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Sichere ProgrammierungFliproom: a room changeover is a content problem(21.09.2026 um 04:10 Uhr)
Sichere ProgrammierungNova Adiutrix: My Second Agent Built My First Project's To-Do List(21.09.2026 um 04:11 Uhr)
IT Security ToolsAntiphishing v35456910988(21.09.2026 um 02:35 Uhr)
IT Security Toolsbrave-browser v1.98.12(21.09.2026 um 03:35 Uhr)
Sichere ProgrammierungFliproom: a room changeover is a content problem(21.09.2026 um 04:10 Uhr)
Sichere ProgrammierungNova Adiutrix: My Second Agent Built My First Project's To-Do List(21.09.2026 um 04:11 Uhr)
IT Security ToolsAntiphishing v35456910988(21.09.2026 um 02:35 Uhr)
IT Security Toolsbrave-browser v1.98.12(21.09.2026 um 03:35 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

DI in my team

Reagiere als Erste:r — dein Feedback zählt!

Bespoke will use Cake Pattern based DI.
We will split the code in different components, each one with a clearly defined scope.
For each component we will define 3 things

  1. A trait
trait MyService{
  ...
}
  1. A binding key
object MyService{
   trait Required {
      def myService:MyService
   }
}
  1. An implementation
final class DefaultMyService extends MyService {
...
}

Let's avoid the Impl suffix (as explained here)

  1. A Binding
object DefaultMyService {
   trait Provided extends Required{
      final override lazy val myService: MyService = new DefaultMyService()
   }
}

Finally, for the application we will have

  1. Modules

Which are the grouping of multiple bindings

trait MyModule extends DefaultMyService.Provided
with DefaultMyOtherService.Provided
with DefaultMyRepo.Provided
with DefaultMyClient.Provided{
}
  1. Containers
new MyModule with MyOtherModule with YourModule{}

Binding keys

Binding keys are the key to which a component will be associated.
In our case will be a trait called Required as part of the companion object of the trait we want to bind.
That trait will have one single method (def) without parameter lists, whose return type will be the bound trait, and whose name will be clear and explanatory and not prone to collisions.
It's important that it's a DEF and not a VAL, because order initialization is required when using VAL, which makes it very difficult to get right.

object A{
   // NO EXTRA MIXINS
   trait Required{
      // NO SELF ANNOTATIONS
      def a: A // DEF, NOT VAL, NOT LAZY VAL... DEF!
   }
}

Bindings

Bindings are defined by a set of dependencies, and a constructor using such dependencies.
In our case it will be a trait in the companion object of out implementation class.
That trait will extend ONLY the Required trait and will implement the method as lazy val (in case of singletons) or def (in case of non singletons).
For good measure a final modifier is encouraged, and for readability an override modifier.
Dependencies will be declared as self annotations, NOT mixins... SELF ANNOTATIONS.
And self annotations to other Required traits.


object DefaultA{
   trait Provided extends Required{
      self: B.Required with C.Required with D.Required =>
      override final lazy val a = new DefaultA(b,c,d)
   }
}
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten DI in my team

Thematisch verwandte Begriffe: team · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-93977 | A vulnerability was determined in code-projects Assessment Management 1.…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick