This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes OO, Patterns, UML and Refactoring and the fly likes State pattern - Wizard implementation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "State pattern - Wizard implementation" Watch "State pattern - Wizard implementation" New topic

State pattern - Wizard implementation

Omkar Shetkar
Ranch Hand

Joined: Jun 22, 2006
Posts: 41


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 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:
subject: State pattern - Wizard implementation
Similar Threads
struts vs spring framework
Using an Applet inside Struts - any nice idea?
Template Method Pattern
Distributing tasks
mvc question