Jump to content
  • Advertisement
Sign in to follow this  
jffortin

Namespace in a game engine

This topic is 4499 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!