Should the folders in a solution match the namespace?

后端 未结 7 860
予麋鹿
予麋鹿 2020-12-02 06:05

Should the folders in a solution match the namespace?

In one of my teams projects, we have a class library that has many sub-folders in the project.

Project

7条回答
  •  悲哀的现实
    2020-12-02 07:01

    Also, note that if you use the built-in templates to add classes to a folder, it will by default be put in a namespace that reflects the folder hierarchy.

    The classes will be easier to find and that alone should be reasons good enough.

    The rules we follow are:

    • Project/assembly name is the same as the root namespace, except for the .dll ending
    • Only exception to the above rule is a project with a .Core ending, the .Core is stripped off
    • Folders equals namespaces
    • One type per file (class, struct, enum, delegate, etc.) makes it easy to find the right file

提交回复
热议问题