Saturday, June 28, 2008

Structuring a solution and project

How do you structure a new solution in Visual Studio?

Typically, within about 10 minutes of starting a new solution is VS2008, I will have 10 projects in that solutions. They are:

  1. The Application
  2. The Business Layer (BLL)
  3. The Database Layer (DB)
  4. The Logger
  5. The Utility Library

And then for each of those projects I have a unit test project. The new projects are the App, BLL, and DB. Items 4 and 5, the logger and utility library are used in all projects and when I find that a project needs a bit of functionality that's in another project I move it to the utility library so both solutions can share it.

Almost all of the code for any solution will go into the BLL. I try and put everything in there. The DB provides a facade to the data store and I try and keep the UI as thin as possible so that all the logic can be tested in the BLL. Whenever possible I'll use an interface and inject the dependent object into the relevant class so that I can mock the object during testing. For testing I use Visual Studios built in test harness and for mocking I use Rhino Mocks.

No comments:

Post a Comment