We need to build a solution to process sales orders. The processing is done serially: each step takes care of specific tasks: check if the client has credit, check if the required item is in stock, etc.
We thought of using the chain of responsibility pattern.
I found this old but very valuable article. It starts by comparing CoR with the Template pattern. Since we are not concerned about coupling, both of them seem to work.
Are there any disadvantages (or pitfalls, etc) that I should be aware?
It's not really a good fit: the Chain of Responsibility pattern is about delegating tasks that the earlier steps can't handle.
In your case you want every step to be applied so CoR doesn't really apply.
What you really want here is some kind of business process engine like jBPM. Process engines are designed to handle exactly this kind of situation and give you many features that would be tricky to implement in a hand-rolled solution, e.g.:
Basically, this is one of those situations where I would advise against reinventing the wheel.....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With