Self types and the cake design pattern

What we saw in our preceding examples was a pure example of dependency injection. We required one component to be available in another one through self types.

Self types are often used for dependency injection. They are the main part of the cake design pattern, which we will become familiar with later in this book.

The cake design pattern relies completely on self types. It encourages engineers to write small and simple components, which declare and use their dependencies. After all the components in an application are programmed, they can be instantiated inside a common component registry and made available to the actual application. One of the nice advantages of the cake design pattern is that it actually ...

Get Scala Design Patterns - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.