I have a state machine that will collect/generate data at different states and the data will then be used in some later state again. How do I transfer the data between states?
- Use a singleton object to hold the data
- Pass the data from state to state until it is no longer needed.
Both options seem ugly to me, is there a better one? Or maybe I should use another pattern instead of a state machine?
Motivation: The problem I'm trying to solve is to process a long text file where each line starts with a numeric id followed by data.