9

I have a Visual Studio Solution with 3 projects:

  • MyWebSite (A)
  • BusinessModel (B)
  • Persistence (C)

Persistence, project C, depends on NHibernate and contains all of the repository interfaces, Hibernate implementations of those repositories, and the classes which map to the DB tables.

BusinessModel, project B, depends on C and contains all of the service classes and classes representing the business domain entities. These services use the repositories to retrieve data and then transform that data into business representations the surface in their own interfaces.

MyWebSite, project A, depends on A and contains all of the MVC classes/files. The MVC controllers here use the service class from B to do any business logic functions. There is no knowledge from this level that project B uses project C's repositories to perform its operations.

In a perfect world, I would imagine that project A should reference B which references C which references NHibernate. This does not seem to be true. I find that project A needs a reference to B and C and NHibernate! I don't like the idea of my web application needing knowledge of my back-end architecture and I especially don't want it aware of the fact that I am using NHibernate as my ORM.

Is there a way to tell these projects to utilize transitive dependencies when resolving their references?

My project is .NET 4 in Visual Studio 2010, if that info makes any difference.

EDIT: I found this SO answer to a related question which explains these references are only needed if project C's classes are surfaced from project B. I have been very determined to not have any leaks between layers and I know Hibernate classes are only used in C so maybe I just don't understand correctly...

Community
  • 1
  • 1
Jesse Webb
  • 43,135
  • 27
  • 106
  • 143
  • You may want to do some reading into the onion architecture. It might help you out: http://jeffreypalermo.com/blog/the-onion-architecture-part-1/ – rie819 Sep 08 '11 at 17:48
  • @rie819 - I have also used the Onion architecture in other projects, just not any .NET ones. I believe it would be prone to the same dependency/reference problem however where the app itself would need knowledge of any transitive dependencies because their are still layers to the architecture. The Onion pattern simply moves some of the concerns to different levels, but there are still levels and I would like to keep the outer/top levels agnostics to the implementations of lower levels. – Jesse Webb Sep 09 '11 at 14:00

0 Answers0