O'Reilly logo

Domain Modeling Made Functional by Scott Wlaschin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Injecting Dependencies

We have a number of low-level helper functions, such as toValidProductCode, that take a function parameter representing a service. These are quite deep in the design, so how do we get dependencies from the top level down to the functions that need them?

If we were doing object-oriented programming, we would use dependency injection, and possibly an IoC container. In functional programming, we don’t want to do that because the dependencies become implicit. Instead we always want to pass dependencies around as explicit parameters, which ensures that the dependencies are obvious.

There are a number of techniques for doing this kind of thing in functional programming, such as the “Reader Monad” and the “Free Monad,” but since ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required