Tip #18 -Separate Request Origination From Processing
Often times you have a core piece of processing logic that weaves together a variety of components and services in order to fulfill use cases. The processing logic might be a sequential procedure, a stateful business process, or a stateless service capability. You typically implement complex processing within the context of projects that has a defined manner in which the processing logic will be invoked. It is useful to decouple request origination from processing. The idea is that you want to reuse the processing logic in a variety of scenarios and don’t want to depend on the specific nature of how requests are sent for processing from a particular application. For example, let’s say you implement an order processing service that looks up the order details, executes business rules to validate order information, and runs inventory and credit check and notifies a shipping module. This might be built for an application that sends requests using a web-based form. You can isolate the logic that constructs order processing requests that assumes the execution environment and user type etc. That way the order processing modules can be used via asynchronous messaging, for business-to-business integrations, composite services, etc. Additionally, if you want to invoke processing via bulk upload using an excel file or text extracts you can construct the request accordingly and submit it to the same processing modules. If your processing logic is too tightly bound to a web-based form being the input your reuse potential is diminished. If not, do plan to refactor the tightly coupled logic.