Best way to organize the files in my project

后端 未结 3 873
自闭症患者
自闭症患者 2021-02-11 06:20

What is the best way to organize the files in your project?

For example do you put all user controls in a separate folder or do you place them in a sub folder? Do you h

相关标签:
3条回答
  • 2021-02-11 06:55

    I separate our major chunks into projects - makes it very easy to reuse.

    Within a project I do folders (and names) by functional areas.

    That's as far as I go on a generic basis - the needs of the project determine any further partitioning.

    0 讨论(0)
  • 2021-02-11 07:10

    First the purpose of folder separation is to be an extra level of documentation, to let the programmers find code easier. That means you should not have extra levels "just to organize stuff". That excludes folders named Classes, Controls, etc.

    Some examples:

    If you work on a thee tier App it would make a lot of sense to have something like:

    Project\Tier (Model|Controller|etc)\Classname

    If you program is big to the point of having separate functional areas I would go with:

    Project\Functional Area\Tier (Model|Controller|etc)\Classname

    That is particularly usefull when sub-teams work on the different functional areas.

    Also refrain from very deep folder trees (IMHO, more than depth 4 is too much) and keep your folder names compact. Some tools might have limitations on path size as low as 255 chars, so this is one place where brevity has its place.

    0 讨论(0)
  • 2021-02-11 07:11

    I agree with the other answers that suggest naming folders by purpose and not type (i.e. call a folder Model, not Classes and include only data-oriented classes in that folder). Additionally I like to keep all Controls and Data/Model related classes in their own separate projects that are not allowed to reference each other. This can help you enforce the separation between view and model in your code which is generally a good thing.

    0 讨论(0)
提交回复
热议问题