Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Stylistic choices

Name: Anonymous 2011-12-13 3:18

I tend to prefer to use namespaces filled with constants, rather than using enums in most cases. For example using

namespace Element {
const uint8_t No_Element = 0;
const uint8_t Air = 1;
const uint8_t Water = 2;
const uint8_t Earth = 3;
const uint8_t Fire = 4;
};


instead of


enum Element {
No_Element, Air, Water, Earth, Fire
};


Is this bad practice?

Name: Anonymous 2011-12-13 5:47

>>24

There shouldn't ever be a time where you don't know what namespace something is from. The using keyword should be used sparingly, and only in cases where other namespaces with the same variables will never be used.

>>29

There's a reason you have a linker you know. By only splitting up your code into a bunch of header files with a single source file, your compiler is effectively compiling a single giant mess of code. If you happen to make an error in one function, you have to recompile everything else from scratch. You should separate your source code so that you don't have to recompile the entire thing every time something needs to be changed.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List