views:

135

answers:

2

Using nHibernate, (and the repository pattern), how do you go about laying out your files/folder?

I am going to to DDD, and use the repository pattern so I will have lots of classes that map to my database tables, and lots of repositories that inherit from an interface etc.

Something like:

/root/
/root/web.config
/root/class/user.cs
...
/root/repository/UserRepository.cs

/root/interface/iRepository.cs
+1  A: 

For me default project structure is following:

  • Solution.Core

    • Bounded Context (e.g Products, Ordering, Accounting) Contains Entities and value objects
      • Services (Contains interfaces for repositories, services etc)
  • Solution.DataContracts (for DTO-s)

  • Solution.Infrastructure (contains plumbing code)
  • Solution.Configuration (contains infrastructure configuration. NH mappings, IOC registrations, conventions etc)
  • Solution.Services (contains implementation of services like NHibernate repositories etc.)
  • Solution.Presentation (contains presenters or controllers)
  • Solution.Web (contains views and bundles everything together)

It seems to be nicely decoupled and when cyclic dependency comes, it shows that there are probably design problem.

Marek Tihkan
+1  A: 

'Lots' of repositories suggests that you either need to rethink what is really an aggregate root or your domain is utterly insane!

Alun Harford