Are namespaces a good idea for game development? Like, if I do like this:Code:namespace Polarr { namespace Engine { extern class Color; extern class Vector; } namespace Network { extern class Server; extern class Client; } }
Are namespaces a good idea for game development? Like, if I do like this:Code:namespace Polarr { namespace Engine { extern class Color; extern class Vector; } namespace Network { extern class Server; extern class Client; } }
Yes. Anything with more than one "section" should use namespaces.
Namespaces and whitespace are a good idea, they make the code clearer, and laot easier to amend and view. also, in the real world, just think of a program the size of final fantasy XII with out spacing... what a mess it would be!!!
swgh, maybe I'm wrong, but from your post it would apear that you do not know what a namespace is. It has nothing to do with spacing and formatting, it is like a class but you don't create an object for it. They would be important in a large game with many programmers, because if they each have a different namespace, they don't have to worry about giving variables the same name without knowing it.
- SirCrono6
From C to shining C++!
Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
- Bubba
IDE and Compiler - Code::Blocks with MinGW
Operating System - Windows XP Professional x64 Edition
I think namespaces are good, although, with classes and such most namespace clash issues have been resolved, even in larger projects.
I tend to use namespaces to create 'modules', if several classes are always/often used together I group them in a namespace. A quick example (not from a C++ project actually, I used Ruby) is a small app I wrote at work.
It's used to manage the data we have stored about the assets in our company, so each asset is modeled within the class Asset, then I have an AssetCollection class to collect assets and also a Validator class to validate asset IDs (you wouldn't believe how mangled some of the input is ).
Each of these are grouped in a module (Ruby's version of namespaces) called Asset, so Asset::Asset, Asset::AssetCollection and Asset::Validator.
I find the best way to think about namespaces is to think of them as logical groupings of classes.
Originally Posted by swghFunny, I thought he was kidding .Originally Posted by SirCrono6
Eh I don't like namespaces. They ARE a good idea, but I think that it's more personal preference. I guess if you are on a large project...I really just don't like them, I guess it's my problem
Stan The Man. Beatles fan
When I was a child,
I spoke as a child,
I thought as a child,
I reasoned as a child.
When I became a man,
I put childish ways behind me"
(the holy bible, Paul, in his first letter to the Cor. 13:11)