java bll dal,BLL和DAL之间的通信

Solution setup:

DAL (class library)

BLL (class library)

Common (class library (some common functionality - enums, logging, exceptions,...))

Application1 (Windows Application)

Application2 (Windows Application)

WebApp (Web application)

...

Let's say I have a Customer entity, which is:

a table in SQL server

a CustomerDataTable in DAL

a Customer class in BLL

a BLL.Customer class in all the applications

What kind of objects should BLL and DAL use for communication - DataTable or List (for example)? In first case, BLL logic should transform Customer object to DataTable and send it to DAL. In secod case, DAL layer should be aware of Customer class, which is in BLL layer. But originaly DLL references DAL and not opposite...

Should I put all classes into seperate assembly, which is referenced by all others (Common, BusinessObjects, ...)? In this case I could use Customer class in all my projects.

Should I even bother to seperate DAL and BLL when I know, that only one BLL will use my DAL. In this case I could merge them together into one project.

PS - I am reading about DataTables and a lot of people say that we shouldn't use them at all. What are better options? Maybe it is time for me to learn some ORM mapping tools :)

解决方案

In my opinion you should have another Layer (seperate dll). Like "domain", where would you keep all entities like Customer.

Then simply include in all higher levels(DAL, BLL, UI and others) in hierarchy this assembly.

Sample architecture can look like this:

(Database) DAL BL UI

and on all levels you will have access to "domain" layer.

DAL should return List not a DataTable. On some stage your development process you may want to use in DAL some OMR like NHibernate with would also return a List, probably.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值