4 ms·
You don't want your business logic to depend on anything other than interfaces that it "owns". The actual database access code would be an implementation of suc
by thijsvandien 7y ago
You don't want your business logic to depend on anything other than interfaces that it "owns". The actual database access code would be an implementation of such an interface. In other words, the business logic specifies in abstract terms what it needs, and the code surrounding it provides that.
- veeralpatel979 7y agoThank you for this comment; I will keep this in mind. When working with a language like Go, where I have a DB access layer where I'm running raw SQL queries, I agree with this. When working with Rails, though, I typically just make ActiveRecord calls in my service layer; it's simpler.
- insulanian 7y agoHow do you write unit tests your service layer then? Unit testing is much more important in dynamic languages, because there's no compiler to protect you from basic mistakes.