Global variables are considered to be bad practice and can be extremely difficult to debug, e.g. when there are a gazillion places where your code writes to or reads from that variable, and in particular if the content of the shared/static variable influences the logic of your code, e.g. when used in an if-statement.