Matthew Delves Part of DW18
State Machines are an amazingly powerful but often under-utilised tool amongst iOS developers. As iOS apps become more and more complex, the business rules and logic introduced into the apps grows. There’s a need to be able to handle all of the rules in an app and make sure that the user experience is amazing and delightful. State Machines are a great tool to use when approaching problems that have intricate rules for navigation between parts of the app. This talk aims to equip the listeners with the knowledge around what a state machine is, how it solves problems and what it looks like in an iOS app.
A State Machine is a pattern that allows for navigation between a finite list of states that are defined. By using a finite list of states, we are able to define precisely the users interaction with a part of an app and make sure that the user doesn’t reach a point where they shouldn’t be. The State Machine is then responsible for defining the possible transitions between the states. What happens before a state transition and what happens after a state transition. To achieve this, I will demonstrate the code that drives a State Machine and how it allows for and prevents the interactions. There’ll be demonstration around how the state machines can be tested. There’ll also be discussion around the tradeoffs between compile time and run time checks with regard to the usage of state machines and what the alternatives are.
In the end, I hope that the listeners will be able to take some of the following away from the talk:
- Knowledge of what a state machine is
- Knowledge of when a state machine should be used
- Knowledge of when a state machine shouldn’t be used
- Ability to define a state machine in swift
- Ability to translate theoretical ideas into solvable problems in iOS apps by using a state machine
This talk will encourage people to use the pattern appropriately and not be frightened when encountering them in the wild.