7

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?

BuddyJoe
  • 69,735
  • 114
  • 291
  • 466
  • Should have included the test projects. thx – BuddyJoe Apr 14 '09 at 14:56
  • Was going to have a look at what CodeCampServer does. Can't check out the source code. Weird repository has relocated error. Anybody else able to check it out? details: http://code.google.com/p/codecampserver/source/checkout – BuddyJoe Apr 14 '09 at 15:23
  • 2
    Your business logic should be in domain. – Paco Apr 14 '09 at 18:54
  • 1
    I guess in a DDD sense I meant services. I would have some business logic related to Entities in the Domain. – BuddyJoe Apr 14 '09 at 21:35

4 Answers4

3

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
  • 8,138
  • 1
  • 28
  • 27
2

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.

Michal
  • 95
  • 2
  • 9
James Avery
  • 3,062
  • 1
  • 20
  • 26
2

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
  • 48,427
  • 16
  • 81
  • 117
1

You can see how it is done in s#arp architecture. Its a very solid architectural framework

Sly
  • 15,046
  • 12
  • 60
  • 89
  • As of 2019, this domain appears to have expired. It now points to a domain parking page. – ajxs Jun 02 '19 at 06:11