5 ms·
I think the main insight from "functional core, imperative shell" is more about structuring the code so as to be easy to test. Without that structure, code ten
by rgoulter 12d ago
I think the main insight from "functional core, imperative shell" is more about structuring the code so as to be easy to test.
Without that structure, code tends to be difficult to test, since the impure stuff like network requests is part of the same sequence of statements as the logic you want to test. (That is: pure code is easier to test (but harder to write real programs with).. so, "arrange the code so you've got a well tested core" is a good strategy).
The nice part about the pure/functional is that you know for the same inputs, you always get the same outputs. -- I think if you want to say, "well, this stateful object is still pure (if you consider the state part of the input" then sure, I guess.
- cryptonector 12d agoCorrect. FCIS is about testing. Testing pure code is a lot easier than testing impure code, but most of what you want to implement can be done with pure code, and you can isolate the impure code to a shell that can be tested apart from your pure business logic.