Sign in to follow this  
freeworld

use namespaces or not?

Recommended Posts

freeworld    341
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.

Share this post


Link to post
Share on other sites
_the_phantom_    11250
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.

Share this post


Link to post
Share on other sites
freeworld    341
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

Share this post


Link to post
Share on other sites
wicked357    2424
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.

Share this post


Link to post
Share on other sites
nullsquared    126
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.

Share this post


Link to post
Share on other sites
Ariste    296
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this