3 ms·
Why shouldn't a service call other services? One Service may extend the features e.g. network < encryption < http.
by kenniskrag 6y ago
Why shouldn't a service call other services? One Service may extend the features e.g. network < encryption < http.
- Ma8ee 6y agoI don’t think the comment implies that a service can’t be layered.
- kenniskrag 6y agolayering is just a stronger agreement compared to composition imho.
- exabrial 6y agoYes. So something like a "DatabaseService" might have a database connection, which is code we don't own. But the code we do own stops at that layer. This prevents a spider web of dependencies opening up.
- exabrial 6y agoThree reasons: First: we found that it creates a spider web of dependencies if we din't have this rule. Instead, if you return control to the controller after performing a discrete action, it makes sure that business logic stays out of services and keeps service functions short and directed. Second: it makes it easy to keep the entire design in your head. Third: It promotes composition. This leads to easier testability with mocks rather than having to resort to full blown integration tests for even the smallest things. (We still do integration tests, but mock tests can be churned out in volume and are less fragile).