I was talking with my boss recently about composing services from other services (in a Service-Oriented Architecture, if you haven't already guessed). We disagreed on some architectural principles and I'd like to find some articles to read around the subject to help the discussion.
My thesis is that injecting services into other services is fine. For example, I have no issues with doing the following:
class SomeService {
protected $anotherService;
public function __construct(AnotherService $anotherService)
{
$this->anotherService = $anotherService;
}
public function doSomething()
{
...
$this->anotherService->getWhatever();
...
return $someObject;
}
}
Some colleagues (and my boss) seem to think that this is not a good practice. Their hard rule is that a service cannot depend on another service, only a repository (or something in the architectural layer below it). The ramifications for this is that we have a lot of duplicate code, but they claim that something feels unclean about composing services from other services.
Are there some articles, books etc. out there that would be useful to consider?