Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The absolute worst type of global mutable state I've had to deal with personally follows this antipattern:

    oldEnvironment = getGlobalEnvironment()
    SwitchToGlobalEnvironment("Foo")
        - Do things that rely on the "foo" globals
    SwitchToGlobalEnvironment(oldEnvironment)
Or, worse, functions like this:

    // NOTE: DO_STUFF assumes "FOO environment". Set FOO ENVIRONMENT before you call it.
    def doStuff() {
       - Do stuff that relies on foo environment
    }
or:

    // NOTE: depends on the value of global FooBar. Adjust FooBar to make DoStuff2 behave how you want
    def doStuff2() { ... }


I suppose you never worked with old ASP or PHP apps where the first thing every page did was throw every form field value into the global Session object?


I've worked with a library in which the file currently being read/written was maintained in global state. Not fun at all.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: