views:

18

answers:

1

I have 3 major layers: UI->BL->DL (and I'm using Active Record/Nhibernate if it matters).

My question is simple: where should TransactionScopes and ISessionScopes be implemented? My idea is to use transactions either on BL or DL and ISessionScopes only on BL, wrapping multiple (or not) methods from DL so they will share one session.

Is that correct or I'm making design mistake here?

A: 

DL, The rule of a thumb is to make as little commonly known data types as possible, so you will be able to replase the implementation with minimum effect on other layers. Since the data source can change from one to another the BL shoudn't even care about the DL impemintation

tsinik
I'm not convinced. I will never need to switch data source. You basically mean writing everything what BL makes on DL side, right? Right now my methods in BL wraps all DL-code in a session...
StupidDeveloper
No, not realy. It dosen't matter if you never swich your data source, but in most cases you will change the clases and the methods and will have to change the BL too, which in time will become a hell to maintain, this is why you want as little "coupling" as possible.By the book the data layer should encapsulate the spesific data Select,Insert,Update related managment...a center point to your data base nothing more... no logic...no calculations only abstract data source that the BL will use,the Buisness layer should deal with the buissnes related manipulation only.
tsinik
I totally agree! So imagine a really complex method with calculations that will be using like 10 different datasources(DL). I'm saying this should be put in BL and wrapped in a SessionScope (or Transaction if applicable) and you're saying that it should be somehow put on the DL layer. How ?
StupidDeveloper
As always there are reasonble exceptions from the rules, I need to see the code in order to try to think is this the case for such an exception...But you should answer yourself why your soluttion is better than the alternativs... if your answer is convincing, go for it :-)
tsinik