in reply to Re^2: Is there an ideal module size or subroutine size?
in thread Is there an ideal module size or subroutine size?
A state machine is a perfect example of what I was talking about with moving the long stuff to a data structure. Then you have a small dispatching routine and probably a long, repetitive data structure but no long code that you are trying to understand the structure of.
I've worked a lot with state machines. With a non-trivial state machine, you don't look at the code to understand the state machine, you look at the state diagram. And the routines for each state are usually quite small, often tiny.
For more casual state machines, factoring out the per-state actions is often important because otherwise you can't see how the states relate.
So my guidelines for factoring out code from a state machine routine based on size are the same as for other code. And it is usually easier with state machine code because one state makes a perfect chunk to factor out.
- tye
|
|---|