Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

We are faced implementing a registration workflow with many branches. There are three main flows which in some conditions lead to one another. Each flow has at least four different steps; some steps interact with the server, and every step adds more information to the state. Also the requirement is to have it persistent between sessions, so if the user closes the app (this is a mobile app), it will restore the process from the last completed step with the state from the previous session.

I think this could benefit from the use of the strategy pattern, but I've never had to implement it for such a complex case. Does anyone know of any examples in open source or articles from which I could find inspiration? Preferably the examples would be from a live/working/stable application.

I'm interested in Java implementation mostly; we are developing for Java mobile phones: android, blackberry and J2ME. We have an SDK which is quite well separated from platform specific implementations, but examples in C++, C#, Objective-C or Python would be acceptable.

share|improve this question
Hi Eugen and welcome to Programmers! You will have to tell us a bit more about the workflow, non trivial implementations are rarely based around a single pattern. Also, although we are focused on language agnostic questions, since you are asking for examples it would be helpful to tell us what languages you are familiar with. But keep in mind that most people here will be more interested in the conceptual side of your question. – Yannis Rizos Jan 24 '12 at 7:12
Hi Yannis, thank you for correction. I've added languages but as you said it's quite general question that should be clear for any oo language. – Eugen Martynov Jan 24 '12 at 7:26
Sounds like a "chain of responsibility pattern" coupled to a factory for strategies for concrete steps. – Falcon Mar 24 '12 at 18:41

3 Answers

Here is an example that does exactly what you are looking for. The example handles a web registration process that is persisted so the user can resume where they left off. It is implemented using ASP.NET MVC in C# with Windows Workflow Foundation.

share|improve this answer
Thank you Kevin. Our flows are a has more branches but article is helpful. – Eugen Martynov Jan 25 '12 at 18:21

As @Kevin Junhans alreayd pointed out, this problem is really a question aout implementing a workflow. The strategy pattern isn't really applicable, it's purpose is more to make code generic by swapping out small portions of logic contained in "Strategies", not in orchestrating a larger process.

For Java there are a lot of workflow related options, of which I know two free & open source ones:

  1. jBpm
  2. Activiti
share|improve this answer
Hi Chris! Thank you for reply. Going to process resources soon. – Eugen Martynov Mar 12 '12 at 15:01

You should have a look at JHotDraw. It's sole purpose is to demonstrate patterns usage in real life.

share|improve this answer
Thank you! I will check it. – Eugen Martynov Mar 27 '12 at 8:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.