3 ms·
If it helps anyone: I find it typically easier to ask “can I extract data and functions out of here” rather than “can I extract the side-effects out of here”.
by dgb23 4y ago
If it helps anyone:
I find it typically easier to ask “can I extract data and functions out of here” rather than “can I extract the side-effects out of here”. And I found that asking this question too early can be detrimental if you’re still trying to figure stuff out.
I don’t follow the paradigm strictly and I often write code in order to understand something. The first draft is typically just procedural with minimal abstractions. It’s more efficient that way.
Only after it’s working I start to pull out the pure bits and write tests for them.
- Leftium 4y agoThat's actually exactly how the author (Gary Bernhardt) describes implementing Functional Core, Imperative Shell: > This is the cadence of the entire project so far. I tend to bloat up this outer file to something like 250 lines in some cases. Then I extract behavior out, moving it into unit-tested classes, figuring out how to make it more functional. Skip to about 11:40 in the video. (There is some additional explanation right before that.)