4 ms·
I have coded somewhat like this before, where my methods were mostly static. It feels good, but it really didn't give any return in the sense of making my code
by haburka 9y ago
I have coded somewhat like this before, where my methods were mostly static. It feels good, but it really didn't give any return in the sense of making my code less complex or easier to test. Generally it's actually very easy to test a method that isn't purely functional, due to simple object creation during the testing process.
As far as complexity, it just meant that I would make the first argument of the function the object that I was modifying. So basically, the function might as well have known about this in the first place. Eventually I just moved back to class syntax and I didn't miss it.
I honestly don't understand how to do JavaScript in a purely functional way. The nature of the beast is that user input modifies data, which results in changes in state. To me, that's a contradiction of the functional paradigm, and it is better to be functional when you can and otherwise just be explicitly stateful.