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

I think one of the main complaints about global variables is that because you can change them from anywhere within the code, you are tempted to actually do so, which can get into some pretty nightmare debugging scenarios. If you truly have global state, I think the preferred solution is to have one piece of code which changes/updates the state, but everywhere else may simply read it. Then you at least know where the problem has to be if your state updates are buggy.


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

Search: