Browse - Programming Tips - How can I reduce the number of global variables in a codebase I inherited?

Date: 2017may5
Language: any

Q.  How can I reduce the number of global variables in a codebase I inherited?

A.  You can convert a global variable into a global read-only function.

For example if you have this javaScript:

var gMyGlobal = 123;
You can change it to:
function getMyGlobal() { return 123; }
Its still global but you know it isn't being updated. There are many other techniques.