.netresharpernamespace-organisation

Arranging/Organizing my classes/interfaces into folders? Not changing namespace with folder (Resharper: Namespace Provider = false)


I currently have a project and its increasing in size everyday. Its a container for an api i am providing.

I currently have in the root all my classes and all interfaces.

I have separated my Enums, Contants, etc into their own folders but i don't inherit the folder as part of the namespace they are just containers to keep them tidy.

I was wondering if anybody has any experience here?

Should i separate my interfaces into their own folder too (not inheriting the folder as part of namespace)

Should i separate my classes also?

I also have classes that are children of other classes .. ie a class implements it as a property. Hence it would never be instantiated outside. So should I separate them even further and put (for example) a folder called "Products" and inside this folder i would have my Product class and then my item class and other classes that are specific to Product?

Again, using the folder as a means of separating and not inheriting the folder name as part of the namespace.

I would love to hear some feedback.

Thanks


Solution

  • These kinds of situations rarely arise in development. In actual fact, in most cases you end up having separate projects rather than a single project with lots and lots of folders. Personally I consider a convoluted project an obvious code smell. If nothing else, your project won't compile as quickly because it gets compiled as a chunk, whereas separate projects can be compiled in parallel (more or less - it's all influenced by dependencies).

    That said, if you really want to keep everything in one project, here's my take on it:

    To sum up - try grouping files by functionality, not by type.