Take the 2-minute tour ×
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
1  
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
1  
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
add comment

3 Answers

As Kevin Junhans already pointed out, this problem is really a question about 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 and open source ones:

  1. jBpm
  2. Activiti

A good workflow engine will help persist long running processes (like when a user exits their session) and orchestrate actions between multiple systems (wait for user input here, call web service here, etc). Done right, your processes will also be easier to adjust in the future and verify with the business.

share|improve this answer
    
Hi Chris! Thank you for reply. Going to process resources soon. –  Eugen Martynov Mar 12 '12 at 15:01
    
would you mind explaining more on what these resources do and why do you recommend these as answering the question asked? "Link-only answers" are not quite welcome at Stack Exchange –  gnat May 31 '13 at 13:16
    
@gnat, How is this a link only answer? First, he needs a workflow engine, not a stratgey pattern. The links are to Java workflow engines, as noted in the answer. –  Chris Pitman May 31 '13 at 18:00
add comment

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

jhotdraw.org is where it's at:

a Java GUI framework for technical and structured Graphics. It has been developed as a "design exercise" but is already quite powerful. Its design relies heavily on some well-known design patterns. JHotDraw's original authors have been Erich Gamma and Thomas Eggenschwiler...

JavaWorld published an introductionary article "Become a programming Picasso with JHotDraw". The accompanying example application JModeller - a simple UML editor built using JHotDraw - shows some of the described design patterns and demonstrates how to use and extend existing classes...

Besides the documentation which is included in the download package more information about the internal architecture of JHotDraw and guidance for using the JHotDraw can be found here:

  • A description of the design patterns used in JHotDraw in the form of a pattern language by Douglas Kirk. Especially, the pattern index in form of a clickable pattern map shows the relation of different patterns.
  • A case study about an older version of JHotDraw can be found in the dissertation of Dirk Riehle...
share|improve this answer
    
Thank you! I will check it. –  Eugen Martynov Mar 27 '12 at 8:29
    
The link you refer to is written in German, would you mind explaining more on what it does and why do you recommend it as answering the question asked? "Link-only answers" are not quite welcome at Stack Exchange –  gnat May 31 '13 at 13:14
1  
1) The question is "can you point me" and a link does exactly that. –  EricSchaefer May 31 '13 at 15:33
2  
2) jhotdraw.org is where it's at –  EricSchaefer May 31 '13 at 15:33
1  
3) "It's sole purpose is to demonstrate patterns usage in real life." That's why I recommended it. –  EricSchaefer May 31 '13 at 15:34
add comment

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
add comment

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.