3 ms·
This is off topic. But I really hate “services”. They always are just some random collection of functions and aren’t a real object at all.
by vips7L 1y ago
This is off topic. But I really hate “services”. They always are just some random collection of functions and aren’t a real object at all.
- koiueo 1y agoI think I know what you are talking about. In a typical three-tier enterprise application there's no clear separation of concerns between "services" and DAO/Repo... And this is due to how most persistence libraries are designed: they eagerly execute side-effects, this breaks composability due to poor transaction control, so you end up leaking a lot of your business logic into your supposedly persistence layer. Take a look at Scala's doobie[1]. Any doobie operation returns a `ConnectionIO`, which is only a description of an operation (free monad). With a proper doobie usage the DAO layer is an algebra of possible persistence-related operations, and the service layer implements business logic by combining primitive ConnectionIOs and interpreting them with full control of transaction boundaries. [1] https://typelevel.org/doobie/index.html https://typelevel.org/doobie/index.html