Is it a bad practice to include all the enums in one file and use it in multiple classes?

Posted by Bugster on Programmers See other posts from Programmers or by Bugster
Published on 2012-12-08T10:33:22Z Indexed on 2012/12/08 11:34 UTC
Read the original article Hit count: 237

Filed under:
|
|

I'm an aspiring game developer, I work on occasional indie games, and for a while I've been doing something which seemed like a bad practice at first, but I really want to get an answer from some experienced programmers here.

Let's say I have a file called enumList.h where I declare all the enums I want to use in my game:

// enumList.h

enum materials_t { WOOD, STONE, ETC };
enum entity_t { PLAYER, MONSTER };
enum map_t { 2D, 3D };
// and so on.

// Tile.h
#include "enumList.h"
#include <vector>

class tile
{
    // stuff
};

The main idea is that I declare all enums in the game in 1 file, and then import that file when I need to use a certain enum from it, rather than declaring it in the file where I need to use it. I do this because it makes things clean, I can access every enum in 1 place rather than having pages openned solely for accessing one enum.

Is this a bad practice and can it affect performance in any way?

© Programmers or respective owner

Related posts about c++

Related posts about programming-practices