I'm working on a building what I'm calling a Process Wizard Builder in PHP. I'm interested in using established design patterns where applicable, but my experience architecting a system like this using design patterns is limited.
Here's the gist of the system:
There are many different process wizards that need to be built (10+). A process wizard is defined as a set of steps required to create or update an entity in the system. The number of steps for a process wizard may vary. Step order needs to be modifiable. Steps can be reused across process wizards. Step functionality needs to be able to be overridden per wizard. Steps each accomplish a specific goal: information gathering, document upload, invoice creation, etc.. Each step also may have AJAX calls to fetch additional data and each AJAX call may need to handle responses differently for each wizard.
In plain English the overarching flow would always be:
- Choose and start a process wizard
- Work through interactive steps defined for that wizard.
- Finally yield new tasks / data for users.
Here's some pseudo-code of what I mean by flexible design:
Runs Step1, Step3, Step4;
$step_order = [1, 3, 4]; // Order can be anything
Runs Step1, Step2, Step3, Step5;
$step_order = [1, 3, 2, 5]; // Order can be anything
// Override one of the steps;
// Different step2 code.
I'm currently doing this without any establish patterns. I'm using an abstract parent class, traits, dynamic method calls keyed off of step names, and a step order array. It works, but I can't help thinking that there may be better or more expected approach. I'm wondering if there is a combination of design patterns that may be a better choice for something like this.
I feel like the answer may be some combination of Builder, Factory, and Decorator. My experience implementing design patterns is limited so thoughts from those with more experience would be great.