I always struggle with naming namespaces when working in a team. I'd be very thankful if someone could share your preferred way of namespacing gameplay code? At least the root namespaces.

Edit: As this question has been downvoted I'm adding more details - I'm basically looking for a namespacing template/examples that could be easily reused on many projects and won't have names like MarioCharacterNamespace which will obviously last a week. Also no maintenance greedy dependencies like depending on the company name or project name. I also tend to end up with very long namespaces like Game.Battle.BattleLogic.Controllers.Enemy and such that I'd also like to avoid.

So some template that's not too specific nor too general and can easily be reused on many projects at least in the beginning.

  • 3
    \$\begingroup\$ Attempting to steer this from very broad toward good subjective: Is there a specific way of naming that you've tried, which you've found problematic? Why has it been problematic? \$\endgroup\$ – Anko Oct 28 '15 at 13:30

Name it in a way that will be obvious to anyone reading it. If you are going to have alot of classes for Objects, perhaps have something like companyname.gamename.objects, all your game logic-related classes could go in companyname.gamename.gamelogic

It doesnt really matter what you call the classes or the namespaces, but having a system that you can take a look at the first couple of lines and go "ah yes, this belongs to this subset of code and will probably alter this level of the game" can make things a lot easier, especially in larger projects.

  • \$\begingroup\$ And instantly I see tons of problems: why depend on a companyname? You move to a different company - rename everything? Why depend on the gamename - constant maintenance and thinking if the class is only relevant to this game or it might be reussed in another game? I'm basically looking for a template that could be easily reused on many projects and won't have names like MarioCharactersNamespace which will obviously last a week. \$\endgroup\$ – mt_ Oct 28 '15 at 13:36
  • 1
    \$\begingroup\$ But if you are working on a game, you will generally be creating that game under one studio? You shouldn't be moving from studio to studio with it. This is clearly too objective for anyone to give you a definite answer on. In any case, those were just examples. I stated what your naming conventions could be influenced by. Name it in a way that will be obvious to anyone reading it.. At no point did I say "you must use this naming convention.". \$\endgroup\$ – Trotski94 Oct 28 '15 at 14:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.