[ACCEPTED]-Which design pattern to do this?-workflow
This is solved with the State pattern. If you test drive 1 the logic it'll go smoothly.
Sounds like Template method pattern.
Or you can do this via composition 2 and Strategy pattern.
If you start to have complicated logic, then 1 State pattern could be better.
If you're working in C++: Resource Acquisition is Initialization.
This problem 3 generally hasn't been solved well in languages 2 without some sort of deterministic finalisation 1 (C#, Java etc.)
State Pattern my firend is what will make 1 this work at end.
In C#/.NET, we have the
IDisposable pattern. I'm sure 9 you could implement something similar in 8 another language, whether or not it has 7 a garbage collector (though the implementation 6 would differ slightly).
Regarding the workflow 5 aspect of this, I would just follow the 4 design pattern of web services in WCF (i.e.
Begin and 3
Cancel methods). If you don't consider it overkill 2 for your circumstances, the Windows Workflow Foundation may be the 1 best way to go.
More Related questions