-
Dependency Injection in Clojure
Dependency Injection seems like an Object-oriented technique. Can you even do Dependency Injection in Clojure? Yes, you can do Dependency Injection in Clojure. Do you need a Dependency Injection library in Clojure? No, you don’t need a DI library. Instead of that… In a single composition root function, you can pass all of the dependencies…
-
Clojure Multimethods: The Open Closed Principle
Bertrand Meyer’s Open Closed Principle states that adding new behavior shouldn’t change existing code. It should only extend code. Clojure has a great form for that: The Multimethod For example, here’s a data store similar to Redis®. You can run commands like: That works fine. But now, we want to implement an “ECHO” command: And…