The technique of converting the state diagram to code
a) Identify all major control paths. Start from initial state; choose a path across the diagram that corresponds to normally expected sequence of events. Write names of states beside the selected path as a linear sequence.
This will be a sequence of statements in program.
b) Choose alternate paths which branch off the chief path of the program and rejoin it later. These can be conditional statements in program.
c) Identify all backward paths which branch off the major loop of the program and rejoin it earlier. This can be the loop in program. All non-intersecting backward paths become nested loops in program.
d) The states and transitions which remain unchecked correspond to exclusion conditions. These can be handled by applying many techniques, such as error subroutines, exception handling supported by language or setting and testing of status flags.