use namespaces or not?

Started by
4 comments, last by Ariste 14 years, 2 months ago
I'm a year into my cs degree and have noticed that I use alot of naming and ordering conventions that don't seem to be "the norm", so I'm trying to break some of those habits, i find it so hard to not prefix member variables with "m", I don't know why. One thing I pondered about recently while looking at the ogre sdk was they don't seem to use any namespaces. so say I have a window class, would it be more common to name it as so or put is in a namespace? SystemWindow or system::Window I prefer the later, but I could see how it might be easier to read without the namespace.
[ dev journal ]
[ current projects' videos ]
[ Zolo Project ]
I'm not mean, I just like to get to the point.
Advertisement
Easier to read is subjective and only in an instance like that; if you are inside the namespace then you can drop the 'system' bit and it becomes clearer.

What not having a namespace does is cause the top level namespace to get polluted and generally full of everything. Logically grouping things is better.

Ogre might well do that, but Ogre also has alot of questionable design choices, to put it mildly.

In short; you lose nothing by using namespaces but gain alot so I'd used them if I was you.
Quote:Original post by phantom
Easier to read is subjective and only in an instance like that; if you are inside the namespace then you can drop the 'system' bit and it becomes clearer.

What not having a namespace does is cause the top level namespace to get polluted and generally full of everything. Logically grouping things is better.

Ogre might well do that, but Ogre also has alot of questionable design choices, to put it mildly.

In short; you lose nothing by using namespaces but gain alot so I'd used them if I was you.


thank you, I'll keep using them then, one last question about namespaces, should the be camel cased, or capital or lower case all the letters. ie

mySystem
MySystem
mysystem
[ dev journal ]
[ current projects' videos ]
[ Zolo Project ]
I'm not mean, I just like to get to the point.
I think the answer here is your user preference. I prefer all caps, but other library packages use either Ogre is one it uses capital letter then all the rest lower case like Ogre, SFML uses all lowercase sf::Clock clock, etc... So with that pick one that suits you best and your code.
Quote:Original post by freeworld
One thing I pondered about recently while looking at the ogre sdk was they don't seem to use any namespaces.


There's the Ogre namespace which contains all of Ogre's classes. I don't see what other namespaces you'd want in there... for example, RenderWindow is an object that represents a rendering window - it wouldn't make sense to be Rendering::Window or something.
Quote:Original post by freeworld
thank you, I'll keep using them then, one last question about namespaces, should the be camel cased, or capital or lower case all the letters. ie

mySystem
MySystem
mysystem

Namespace::MyClass instance FTW.

This topic is closed to new replies.

Advertisement