Naming Conventions for Project and Solution Folders
Small Solution Structures
If the project space is small I'll just name the folder and solution to match the fully-qualified namespace.
Folderc:\FrogsBrain.MyFancyPants
Solutionc:\FrogsBrain.MyFancyPants\FrogsBrain.MyFancyPants.sln
NamespaceFrogsBrain.MyFancyPants
Larger Solution Structures
If the solution directory tree is very deep or there are many projects are under the root namespace I will break the solution folders up to remove redundant uses of the root name.
Folderc:\FrogsBrain\MyFancyPants
Solutionc:\FrogsBrain\MyFancyPants\MyFancyPants.sln
NamespaceFrogsBrain.MyFancyPants
This will help keep to avoid errors when a path can get too long and wreak havoc with some source control tools.
Project Structures
The project names will follow suit, leaving out the name of the solution.
Folderc:\FrogsBrain.MyFancyPants\Library
ORc:\FrogsBrain\MyFancyPants\Library
Projectc:\FrogsBrain.MyFancyPants\Library\Library.csproj
ORc:\FrogsBrain\MyFancyPants\Library\Library.csproj
NamespaceFrogsBrain.MyFancyPants.Library
OutputFrogsBrain.MyFancyPants.Library.dll
The exception is that the project output will be the fully-qualified name of the project. This makes identifying the assembly easier and prevent collision of names like Library.dll
.
Folders Not Divided By Namespace
Inside of projects I try to follow the same structure but if a folder is not to be included in a namespace or I want to group some files without changing the namespace structure I will create a folder with a "_" prefix.
Projectc:\FrogsBrain\MyFancyPants\Library\Library.csproj
Foldersc:\FrogsBrain\MyFancyPants\Library\_build
c:\FrogsBrain\MyFancyPants\Library\_configuration
c:\FrogsBrain\MyFancyPants\Library\_documentation
c:\FrogsBrain\MyFancyPants\Library\_contracts\ISomeView.cs
c:\FrogsBrain\MyFancyPants\Library\_service\ISomeService.cs
NamespaceFrogsBrain.MyFancyPants.Library
OutputFrogsBrain.MyFancyPants.Library.dll
All files inside of "_" prefix folders are considered to be in the same namespace as their parent folder.
I've tried variations of these structures but will be implementing this as the standard structure for all projects I am responsible for in the future. It's the cleanest and easiest to manage layout I've worked with and has grown from experimentation over a couple years. So, if you look at some of my code and it doesn't already follow this pattern it will eventually.
0comments:
Post a Comment