1
General discussions / why not using a namespace
« on: August 25, 2007, 08:22:21 am »
Yeah, generally the rule of thumb is to not put 'using namespace blahblah' into global scope, unless it is in a cpp file (and even then you might consider only doing it in function or class scope as suggested by PM).
On a game project I'm working on at a certain huge game development publisher, that's the rule we adopted for our team. We have mandated that we namespace-ify all of our code, but we have forbidden 'using' statements in header files except where you can restrict it to a specific scope. All of the intellisense-type tools and whatnot then make navigating namespaces to find identifiers really easy, and it makes for quick identification of where code logically fits into modules and sub-modules.
For C APIs, they use prefixes on their types and functions because, well, there weren't namespaces to do that job even better. For DirectX, it was first developed back when there was no namespace support in C++, and worse, it had to conform to the COM interfaces (which probably didn't easily allow themselves to be put into namespaces, at least when they were first introduced to Visual C++).
On a game project I'm working on at a certain huge game development publisher, that's the rule we adopted for our team. We have mandated that we namespace-ify all of our code, but we have forbidden 'using' statements in header files except where you can restrict it to a specific scope. All of the intellisense-type tools and whatnot then make navigating namespaces to find identifiers really easy, and it makes for quick identification of where code logically fits into modules and sub-modules.
For C APIs, they use prefixes on their types and functions because, well, there weren't namespaces to do that job even better. For DirectX, it was first developed back when there was no namespace support in C++, and worse, it had to conform to the COM interfaces (which probably didn't easily allow themselves to be put into namespaces, at least when they were first introduced to Visual C++).