I'm not a real big fan of state variables, and in fact, for this example,
I had tossed around doing some status checks similar to what you've done,
but rejected it after a couple of false starts.
The problem with state variables is that they introduce some additional
coupling:
- What if the variable gets set to a value other than the legal values (or not initialized)? You could branch more often or less often than you think.
- What if you refactor and now need a finer-grain distinction (stale vs real stale)?
How do you track down which values to check, or does it now need some disjunctive
tests?
- Tracing the program flow now also requires a data simulation as well.
Yeah, again, just reporting on where I've been burned. But I think I've got
enough scars to not just be a guy in a diner on this one. You know, the guy
at the end of the counter who has an opinion on
everything even though
he's not been there? {grin}
-- Randal L. Schwartz, Perl hacker