1

I have four assemblies; UserInterface, BusinessLogic, DataAccess, Common.

The User Interface references the Repository that is in the DataAccess, is that bad practice? Should I create pass through methods in the BusinessLogic so that the UserInterface is not coupled to the DA assembly?

Even in cases where the BusinessLogic method does nothing but call the relevant Repository method?

Or am I being pendantic?

marvc1
  • 3,641
  • 3
  • 25
  • 34

4 Answers4

2

rather than think of the UI talking to the repository, think of implementations depending on abstractions. in this instance the UI depends on IRepository. How IRepository is implemented doesn't matter.

and putting this all into separate assemblies is overkill. just use namespaces to segregate your code. it will be much easier to maintain.

Jason Meckley
  • 7,589
  • 1
  • 24
  • 45
  • I think I've seen how I have led this question to confusion, calling the DA layer the repository was a bad idea, as it does more than just a repo. Question edited. I think I see what you mean, I should move my Irepo out to the common assembly. – marvc1 Jul 05 '12 at 20:13
  • no, unless there is a physical need for multiple assemblies keep it simple with all the components in one assembly. ideally a repository would be highly specific within the domain, not a "common" utility. – Jason Meckley Jul 06 '12 at 12:27
1

If you are trying to do Domain Driven Design then please understand the role of a repository before you think of using it in UI. Very nice explanation here http://devlicio.us/blogs/casey/archive/2009/02/20/ddd-the-repository-pattern.aspx

HatSoft
  • 11,077
  • 3
  • 28
  • 43
1

I thnk you are missing a Layer. Entities Layer or Data Transfer Layer.

It's not definitely ag good practice, an UI have to know knothing about your DAL, that's why You have Your business Layer.

I think You should do it the classic way UI - BL - DAL and backwards should be the same, using Data Transfer Objects

Always using DTO between these layers, transfer objects from the UI to the BL, from BL to the DAL and that way backwards.

Hector Sanchez
  • 2,297
  • 4
  • 26
  • 39
0

I think the main reason of layered structure is 'Seperation of Concerns'. SoC is basicly offer loosely coupling. So reference of UI in DAL is not good thing.

On the other hand, UI should take care of user interaction (not directly calls from DAL). BL should take care of validation and call DAL methods. DAL is the final step and it can validate datas in according to SQL aspects, then handle SQL Statements.

Mehmet Ali Sert
  • 184
  • 2
  • 9