Short Version:
How do you collect the results of a complicated operation that is spread over several objects?
Long Version:
I am developing a data exchange system that will push customer orders from one system to another system. This will be done via an API and unfortunately this require 12 individual steps to be completed successfully in sequence before an order can be reported as successfully transferred.
Although each step can (and has) been broken down into individual units of code, each step HAS to be completed in sequence and some steps depend on the result from previous steps.
Is there a suitable design pattern or combination of patterns that fit well for this particular problem? If each step is dependant on the previous step then whats the best way to make it aware of the previous steps result.
I was thinking of a Composite/Macro Command design or perhaps modelling the OrderPush process as a Finite State Machine although I was hoping to keep it more simple.
This is a question about system design so there is no need to go into detail on what the API is or how it works and I'm only expecting to be pointed in the right direction.
The process is to read relevant data from a local system and push to a remote system via XMLRPC.
The steps are:
- Create Customer
- Create Order (header record)
- Create Order Lines
- Confirm Order (this creates an invoice)
- Find Invoice
- Confirm Invoice
- Create Payment
- Find Journal Item (Journal item relates to the invoice so that the payment line can be tied to the invoice)
- Create Payment Line
- Confirm Payment
Each step is a single XMLRPC call that will either succeed or fail. And this is the crux of it. If the customer failed to be created then none of the other steps will work. Similarly if the order failed to be created then the other steps will either fail or not be able to tie together (i.e. I should obviously stop execution if any previous step fails).
So has anyone got any tips?