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

The article doesn't mention anything about global variables, but reducing/eliminating them would be a high priority for me.

The approach I've taken is, when you do work on a function and find that it uses a global variable, try to add the GV as a function parameter (and update the calling sites). Even if it's just a pointer to the global variable, you now have another function that is more easily testable. Eventually you can get to the point where the GV can be trivially changed to a local variable somewhere appropriate.



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

Search: