Home » Questions » Computers [ Ask a new question ]

Folders or Projects in a Visual Studio Solution? [closed]

Folders or Projects in a Visual Studio Solution? [closed]

"Closed. This question is opinion-based. It is not currently accepting answers.












Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

Closed 2 years ago.





Improve this question





When spliting a solution in to logical layers, when is it best to use a separate project over just grouping by a folder?"

Asked by: Guest | Views: 69
Total answers/comments: 4
Guest [Entry]

"By default, always just create new folder within the same project

You will get single assembly (without additional ILMerge gymnastic)
Easier to obfuscate (because you will have less public types and methods, ideally none at all)

Separating your source code into multiple projects makes only sense if you...

Have some portions of the source code that are part of the project but not deployable by default or at all (unit tests, extra plugins etc.)
More developers involved and you want to treat their work as consumable black box. (not very recommended)
If you can clearly separate your project into isolated layers/modules and you want to make sure that they can't cross-consume internal members. (also not recommended because you will need to decide which aspect is the most important)

If you think that some portions of your source code could be reusable, still don't create it as a new project. Just wait until you will really want to reuse it in another solution and isolate it out of original project as needed. Programming is not a lego, reusing is usually very difficult and often won't happen as planned."
Guest [Entry]

"denny wrote:

I personally feel that if reusable code is split into projects it is simpler to use other places than if it is just in folders.

I really agree with this - if you can reuse it, it should be in a separate project. With that said, it's also very difficult to reuse effectively :)

Here at SO, we've tried to be very simple with three projects:

MVC Web project (which does a nice job of separating your layers into folders by default)
Database project for source control of our DB
Unit tests against MVC models/controllers

I can't speak for everyone, but I'm happy with how simple we've kept it - really speeds the builds along!"
Guest [Entry]

"Separating features into projects is often a YAGNI architecture optimization. How often have you reused those separate projects, really? If it's not a frequent occurrence, you're complicating your development, build, deployment, and maintenance for theoretical reuse.

I much prefer separating into folders (using appropriate namespaces) and refactoring to separate projects when you've got a real-life reuse use case."
Guest [Entry]

"I usually do a project for the GUI a project for the business logic a project for data access and a project for unit tests.

But sometimes it is prudent to have separation based upon services (if you are using a service oriented architecture) Such as Authentication, Sales, etc.

I guess the rule of thumb that I work off of is that if you can see it as a component that has a clear separation of concerns then a different project could be prudent. But I would think that folders versus projects could just be a preference or philosophy.

I personally feel that if reusable code is split into projects it is simpler to use other places than if it is just in folders."