C# Project folder naming conventions

后端 未结 5 1114
轻奢々
轻奢々 2021-02-05 20:19

I have a project called Data which is a data layer. In this project, all files are just lying in the top folder. I have enumerations, POCOs, repositories, partial classes and so

5条回答
  •  青春惊慌失措
    2021-02-05 20:52

    If it is not clear how to group the classes by usage or object model meaning, just leave them all in one folder. Using subfolders don't give values if they don't organise the classes in a meaningful way.

    Dividing folders by type, e.g. enumerations, POCOs, repositories, partial classes etc is not likely to be useful.

    You may wish to use a subfolder for generated code that should not be edited.

    Also remember you can have folders within the solution explorer that are not part of the file system. Given how costly (in time) it is in some source code control systems to move files between directories, I would consider starting of just using msdev folders until you are clear on the structure you want.

    There is no need to put each enumeration in its own file, if an enumeration is only used by one class, it is valid to put it in the same file as the class. E.g the PersonSex enumeration can be put in the person.cs file. Likewise if you have a lot of small and closely related classes, consider putting them in the same file.

提交回复
热议问题