When writing object-oriented software, I often use dependency injection:
To compose high-level functions from lower-level capabilities: My account management service uses repositories and validation services, not their implementation.
to isolate components from their dependencies: my account management service uses its dependencies through interfaces so that I can swap implementations, a layout for unit testing, etc.
What patterns exist in functional programming languages to achieve these goals?
edit: the commentator correctly asks: "but how can I simply skip functions?" I think the following comment about grouping functions strikes a nail on the head - a service is a set of functions with a common set of dependencies that I can process as an atomic group.
In Clojure, it seems that the protocols allow this well, but I'm really interested in how the problem is solved more generally ...
Dan vinton
source share