4 ms·
It sounds like your (more or less) just using classes for just namespacing functions and allowing bundles of functions to get brought in?
by jadbox 8y ago
It sounds like your (more or less) just using classes for just namespacing functions and allowing bundles of functions to get brought in?
- dvlsg 8y agoI've definitely structured f# modules that way. The module exposes one function that "injects" the dependency into multiple other functions, and then returns them as a blob. I'm not sure if that's "the fsharp way" (i suspect it isn't) and maybe I'll look back on it some day and cringe, but it's working pretty well for some of my (admittedly small) side projects I'm tinkering with right now.
- daxfohl 8y agoYes, that's what I do too. "Service" modules contain all the functions, with all dependencies explicitly passed into them, and at the bottom of the module is an interface with the dependencies assumed injected and a factory function that takes all the dependencies and returns an object with that interface. In general I use a suave functional styled api on the top, OO-style SOA in the middle, and mostly functional style at the bottom layer, something of an FP-OOP-FP sandwich. I jokingly call it sandwich oriented programming.
- KallDrexx 8y agoNot the OP but IME with a lot of web/api development work this seems to be the case more than not. I do realize that most web work is really more functional than OOP, but classes do make it very easy to bundle dependencies without adding noise to the implementation/signatures.