I have the opinion that each method in a service should only do one small step of a larger task, delegate a result to the successive step/method and terminate. No matter if this next method lives in the same service or not, it is always triggered via inter-service routing (message queue, service discovery + REST call, whatever ...) and thus perhaps handled by a different instance. Never should the method be called directly by default, unless selectively enabled.
I know, network communication is slower by orders of magnitude and complex tasks with a lot of steps will run milliseconds slower, but this is the only way I see that ensures that
- each step is implemented stateless so that it can - if needed - be replaced in a different technology with no overhead
- failure handling is least expensive as waiting for a response or doing a successive step in the same process increases the chance to loose intermediate step results if that process dies for whatever reason
- definite failure rate is reduced as it is easier and more predictable to implement a standardized failure handling centrally than on method level
Do you think I'm overseeing something and what is your opinion?