I've read a few threads here that people advise against static variables, and the argument is usually because anything global is bad, but besides this, why are static variables considered bad?
Do they perform badly or something like that?
I'm asking because I've got my engine structure with modules, and I'm using static variables for each module so my base classes can access it.
class GameEngine
{
public:
GameEngine()
{
resourceModule = &_resourceModule;
};
static ResourceModule* resourceModule;
private:
ResourceModule _resourceModule;
};
#include "GameEngine.h"
void Image::Load(string imageName)
{
//Texture2D* _texture;
_texture = GameEngine::resourceModule->GetLoadedTexture(imageName);
}
Images are meant to be used like this:
void SomeGameFunction()
{
Image* newImage = new Image();
newImage->Load("imageNameHere");
}
I'm currently doing some encapsulation and blocking accesses to base classes that I don't want exposed, so other programmers don't ever access a "Texture2D" class for example, and when I looked to these static variables I thought they might be an issue but I couldn't find of any good solutions for it, that is, if they require a solution...
So I remembered the topics against static variables I thought I should ask, why are static variables considered bad?