Timeline for When is it ok to use a Global variable
Current License: CC BY-SA 3.0
3 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 19, 2013 at 15:39 | comment | added | jmoreno | No doubt threads can make mutable globals harder to work with, but you can get the same basic problem due to events. I agree with the suggestion to put hem in as static members, and would go further and say that ideally they should be PRIVATE static members. | |
| Aug 19, 2013 at 0:41 | comment | added | ocodo | Ultimately having mutable globals is a pretty bad idea. The only decent exception is when working in extremely tight hardware footprints, such as with embedded programming. At the very least, candidates for globals in regular programming should be parcelled off into static members of classes or modules, anything that's mutable should also be considered a special case, doubly so when working in a multi-threaded environment. Using locking / futures / promises or some other method of thread/transaction safety. - Since no one else mentioned it see the dining philosophers problem. | |
| Aug 18, 2013 at 20:34 | history | answered | jmoreno | CC BY-SA 3.0 |