π³ Namespaces
To maximize reusability for all scripts, just using Game as a namespace is enough to not make it conflict with plugins.
namespace Game
{
public class YourClassName
{
}
}
Complex deep layered namespaces are more of a nuisance than a help to structure code, as it requires knowledge of internal namespaces in order to add the correct using namespaces. This also avoids having code files which contain a large amount of usings listed a the top. Avoid using deep nested namespaces in order for the team to easily find your scripts.
Avoid Game specific namespaces
Why to avoid using a game specific name in the namespace:
- What if the name of the game changes? Renaming all code file namespaces would be required.
- When reusing code for future projects, its will have the previous product names scattered all over the code base such as: using GameNameA; using GameNameB; using GameNameC etc.
Simply stick to the Game
namespace and reuse the code in any future project.
Sub systems
The only place where nested namespaces make sense to use is for lots of small scripts which are part of a larger system, where only files in the Game namespace should be accessed by other scripts and not the internal files.
For example:
namespace | File |
---|---|
Game | PathFinderService.cs |
Game.PathFinder | AStarPathfinder.cs BreadthFirstSearch.cs DijkstrasAlgorithm.cs |