• Post Reply Bookmark Topic Watch Topic
  • New Topic

State pattern - Wizard implementation

Omkar Shetkar
Ranch Hand
Posts: 86
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!