2 ms·
I've worked on similar code. Global state which is sometimes twiddled directly in the main loop, other times functions are called that take no arguments and re
by kbenson 13y ago
I've worked on similar code. Global state which is sometimes twiddled directly in the main loop, other times functions are called that take no arguments and return nothing, but they compute something and set global variables.
Not pretty is an understatement. It's ugly at best, and rage inducing most the time.
- dllthomas 13y agoIt helps when you can use the type system to restrain what can touch what. I've been doing this in some of my high performance C, where some global mutable state is unavoidable - passing around empty structs to indicate context. It doesn't guarantee I don't violate my rules, but it more likely I notice when I do.
- kbenson 13y agoIt's almost never as bad when you design it yourself. Then the logic and reasons are apparent. Coming into such a system from the outside can be tough though. An explanation of the rationale and pre and post conditions is very helpful, even if all it does is keep a future programmer from trying to circumvent the system and causing the problems it was implemented to avoid.