Sign in to follow this  
jff_f

Namespace in a game engine

Recommended Posts

jff_f    372
At first I decided to put everything in the same namespace for my engine. Then I had the idea to put every single lirary in its own namespace. But now my code seems weird because of all the namespaces (I don't use "using namespace"). I'm wondering if this is considered good design to have every single library in its own namespace even if some parts of those libraries are using some parts of others (like my logger lib that uses some of the File manip classes). So this is thread where I'm looking for the opinion of others to guide mine :P. What kind of design would you prefer? Every part of the engine in it's own namespace or only one namespace for the engine? JFF

Share this post


Link to post
Share on other sites
Quote:
Original post by jff_f
(I don't use "using namespace").
JFF

How come?

The use of namespaces is a very good design idea. It keeps all of your code in a managed, clean order. The use of 'using namespace' will save a lot of time and will make the use of namespaces a lot less daunting. Have a look at any manged application and you will see the benifit of namespaces a lot more clearly.

Share this post


Link to post
Share on other sites
jff_f    372
I understand the benefits of namespaces but I wanted to make clear that everything is seperate... that's why I never used using namespace anywhere. But now I think I'm going to use it or to put my engine in only one namespace.

Share this post


Link to post
Share on other sites
janoside    214
I don't know what language/IDE/environment you are using, but if you want things to be separate (at least in C# where I normally develop) it is good practice to separate the engine into separate "projects". This is the Visual Studio term for the idea, but I'm sure that other IDEs may have other terms. In my large works I generally have several projects, each with numerous namespaces. As rpg_code_master said, namespaces are a very powerful construct that should be taken advantage of.

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