Diagram that could explain a state machine's code?

Posted by Incognito on Programmers See other posts from Programmers or by Incognito
Published on 2011-11-19T22:56:57Z Indexed on 2011/11/20 10:22 UTC
Read the original article Hit count: 398

We have a lot of concepts in making diagrams like UML and flowcharting or just making up whatever boxes-and-arrows combination works at the time, but I'm looking at doing a visual diagram on something that's actually really complex.

State machines like those that parse HTML or regular expressions tend to be very long and complicated bits of code.

For example, this is the stateLoop for FireFox 9 beta. It's actually generated by another file, but this is the code that runs.

How can I diagram something with the complexity of this in a way that explains flow of the code without taking it to a level where I draw every single line-of-code into it's own box on a flowchart?

I don't want to draw "Invoke loop, then return" but I don't want to explain every last detail.

What kind of graph is suitable to do this? Is there already something out there similar to this? Just an example of how to do this without going overboard in complexity or too-high-level is really what I want.


If you don't feel like looking at the code, basically it's 70 different state flags that could occur, inside an infinite loop that exists to a label based on some conditions, each flag has it's own infinite loop that exists to a label somewhere, and each of those loops has checks for different types of chars, which then runs off into various other methods.

© Programmers or respective owner

Related posts about documentation-generation

Related posts about diagrams