Service Objects as Functions: A functional approach to build business flows in Ruby on Rails

I wrote this article last year and want to see what you guys think? I have not received much feedback when sharing on LinkedIn.
Original idea was to have a 3-4 post series, but I am not sure is it worth it and if its something people are interested to read about.
16
Upvotes
View all comments
Show parent comment
9
u/art-solopov Oct 12 '24
Ruby does allow us a lot of things, but its FP capabilities are not as prominent compared to the ML family or Erlang or Elixir.
TBH I think your example of state is a bit nitpicky. Good unit tests would catch this kind of bug easily, and the way FP tends to be done (with a pipeline of transformations) doesn't actually prevent this kind of bug (you can just as easily forget to pass the needed data further down the pipeline).
The problem with DI is that, if you have layers and layers of DI (or even, in general, layers and layers of services calling each other), it becomes very hard to reason about the logic. That was my experience, at least. I got lost in a web of open files, each referencing the next one.