How would you replace Factory design patterns in functional programming?
Before someone else says it - with a function
interface ThingFactory {
makeThing();
Thing }
...
void work(ThingFactory factory) {
= factory.makeThing();
var thing .whatever();
thing}
defn work [factory]
(let [thing (factory)]
( (.whatever thing)))
You can also use the exact pattern as is (where the producer method gets a special name) with traits/typeclasses/protocols depending on your FP language