4 ms·
>No! Patterns are just crutches for missing language features > visitor is type switching, singleton global variables, command and strategy are first class fun
by Xmd5a 2y ago
>No! Patterns are just crutches for missing language features
> visitor is type switching, singleton global variables, command and strategy are first class functions with closures
Another aspect of FP is compositionnality.
Singleton -> memoization of zero-arg fn (pro: initialization is implicit)
Memoization -> fn accepting a fn and returning a memoized version
Command & Strategy -> just a lambda then ?
Objects/classes are complex. Composing them is not simple, it means composing every single method. In fact composition is handled as a special case of class derivation, interface implementation or wrapper class implementation usually, i.e. you gotta write another class. OOP has given up on this issue from the beginning. There is no point in building a framework to create classes by composing other classes because you'll have to control how each single method compose with its counterpart. Say farewell to your neat composition expressions, the granularity is not there. Just write another class instead.