File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

State pattern - Wizard implementation

 
Omkar Shetkar
Ranch Hand
Posts: 74
Eclipse IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am refactoring a legacy code to implement wizard. I thought of refactoring using state pattern.
A wizard may consist of related/unrelated steps. Each step can be considered as a state. A controller/context to control the flow of the wizard.

My problem is w.r.to input of flow/sequence of wizard steps. This flow can be handled

1. in controller with lot of if...else statements. OR
2. each state can tell the controller which should be the next state.

Problem with the first solution it will complicate and maintenance will become difficult.
If I go with the second solution, the next state decision will get tightly coupled with the state. If in future I want to reuse the state, I can't resue it since it is tightly coupled with the next state decision behavior.

[moderator corrected the title]

Are there any other ways of inputting/controlling the STEP flow?

Thanks & Regards,
Omkar V S
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic