views:

1184

answers:

3

What do you recommend as the proper project structure for a WebForms solution that is utilizing NHibernate and trying to bring in some DDD concepts?

Assuming the root namespace and solution name is Sample

  • Sample.Domain - contains my domain objects and my mapping files
  • Sample.Repositories - contains my repositories and nhibernate connection config file
  • Sample.Business - contains my business logic
  • Sample.Web - the actual WebForms project - all Presentation

What am I forgetting? Is there a more standard way to name these?
Any great blog posts on the topic?

+2  A: 

I have found everyone has their own preferences for naming, I prefer:

  • Sample.Domain - domain objects, mapping files
  • Sample.Services - business logic and services (and repositories, although I could see separating these out)
  • Sample.Web - Web Stuff.
  • Sample.Migrations - Data migrations.

Ben Scheirman also recently posted about this: Exporting Visual Studio Solutions with Solution Factory

He uses a different structure but also includes a great way to standardize your template.

James Avery
very cool. Have to try out this Solution Factory. +1
tyndall
+2  A: 

A few parts missing seem to be a central location for services needed throughout the solution and test projects. I usually have something like this:

  • Sample.Core - services and code that need to be used across the application
  • Sample.Data - domain classes and repository interfaces
  • Sample.Data.NHibernate - mapping files, fluent config, etc. and repository implementations, basically anything data mapping layer specific
  • Sample.Services - service implementations and interfaces
  • Sample.Web - web application

I have a matching tree of test projects:

  • Tests\Sample.Core.Tests
  • Tests\Sample.Data.NHibernate.Tests
  • etc...

Of course, the tree will get more complex depending on the project. As for discussions, check out the Onion Architecture. You can also check out the sample projects on Domain-Driven Design and see what you can take from those.

Steven Lyons
+1 cool ideas. good links.
tyndall
+1  A: 

I keep it simple and lean towards segregating by namespace rather than by project, especially at the beginning. I usually start with three projects in the solution:

  • Sample - contains namespaces Sample.Model, Sample.Model.Mappings, and Sample.Services.
  • Sample.Tests - contains unit tests is structured the same as Sample.
  • Sample.Web - UI
Jamie Ide
What is the Sample.Model.Mappings for?
tyndall
The Fluent NHibernate mapping classes.
Jamie Ide
Gotcha. Not using that yet. Thanks.
tyndall