Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 323
Dan Avatar asked Aug 04 '08 22:08

Dan


2 Answers

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.

like image 185
lubos hasko Avatar answered Oct 25 '22 23:10

lubos hasko


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!

like image 41
Jarrod Dixon Avatar answered Oct 26 '22 00:10

Jarrod Dixon