This is a demo app showing how the State design pattern can be used to create complex ussd menus.
- Laravel 6
- Africa's Talking USSD Sandbox API
- The classes in the
Ussd
folder represent the various states. - The
input()
method represents the transition between states.- Each state responds to
input
differently.
- Each state responds to
- The
Context
classes manage what gets displayed to the user. - Some functionality had to be placed in the
view
methods of some states.
- Extensible - new states can be created easily by creating classes that implement
the
State
interface. - Clean - each class has concise, understandable methods (hopefully).
- Complexity - the State pattern may be difficult to grasp without first understanding OOP and SOLID
- Numerous files - if a lot of states are involved.
view()
methods have side-effects.