4 ms·
If you want Dont-Repeat-Yourself (DRY), you have to decide to put the domain logic either in the database or in a service*. In the first case, two applications
by vivegi 3y ago
If you want Dont-Repeat-Yourself (DRY), you have to decide to put the domain logic either in the database or in a service*. In the first case, two applications that directly talk to the database is feasible since the common logic is implemented at the database level.
In the latter case, you need to ensure that every application uses the service and no application directly talks to the database. If multiple apps directly talk to the database where the domain logic is in the service layer, you will end up with code duplication and hard to trace bugs (unless you take extraordinary steps).
It is an architectural trade-off. There are use cases where you may choose one over the other.
*: service or library
- rufus_foreman 3y ago>> If multiple apps directly talk to the database where the domain logic is in the service layer, you will end up with code duplication and hard to trace bugs This is more common than putting it in a service in my experience. I haven't seen it done in the database in a new application since the 90's.