3 ms·
If you have curried / partial application, 'construction time' and 'calling time' blur a bit.
by eru 5y ago
If you have curried / partial application, 'construction time' and 'calling time' blur a bit.
- cseleborg 5y agoIndeed, it's never quite black and white. The author's obviously referring to the crazy trends in the Java community back when Design Patterns were the only game in town. I have myself worked on code built like this, it's usually very difficult to retrofit into a unit test. Hell, I've even written some AbstractSingletonFactories myself...
- inopinatus 5y agoThis seems congruent to the object<>closure equivalence. Nevertheless the resulting code reads quite differently. Any kind of early binding to dependencies can read like a “COME FROM” at times (especially debugging time), and all that extra state burns memory. In Ruby one of my favourite calling conventions is to pass self to the methods, rather than the constructor, of collaborator objects.
- eru 5y ago> This seems congruent to the object<>closure equivalence. Nevertheless the resulting code reads quite differently. To write functional code that looks a bit more like OOP, I guess you want 'open recursion'. Open recursion is what allows you to do the equivalent of overwriting methods in subclasses when doing FP. See eg https://www.cs.ox.ac.uk/people/ralf.hinze/talks/Open.pdf https://www.cs.ox.ac.uk/people/ralf.hinze/talks/Open.pdf or https://journal.stuffwithstuff.com/2013/08/26/what-is-open-recursion/ https://journal.stuffwithstuff.com/2013/08/26/what-is-open-r...