通过nTier Web App传递Business Objects [英] Passing Business Objects through nTier Web App

查看:80
本文介绍了通过nTier Web App传递Business Objects的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我希望有开发nTier应用程序经验的人可以在这里给我一些建议。


我正在编写一个以数据访问层(DAL)开头的nTier Web应用程序,

业务逻辑层(BLL)和用户界面层(UIL)。


我发现的问题是循环引用...


我的对象将在BLL中定义,所以让我们说比如说我希望

在UIL中实例化一个新的BLL.Customer对象,然后运行

Customer.AddCustomer(),它会将对象传递给DAL,

让我们调用这个方法DAL.AddCustomer(BLL.Customer myCustomer)将

插入数据库。


问题是BLL需要引用DAL并且DAL需要引用BLL(以接收自定义业务对象)
,因此引用了一个循环

引用错误。我明白我可以将这个自定义对象变成

某种通用对象[]或集合然后传递它,或者

或者逐个传递方法字段值(不实用

10+值)


我所做的是创建第4个垂直层,我称之为ORL
(对象参考图层),其目的是允许所有其他图层

引用相同的对象,以便它们可以在它们之间传递

的问题。缺点是为了使其正常工作,您需要

在ORL中定义对象本身,但是在BLL中静态定义了




我的问题是这个...


这是一个很好的编程吗?


显然它是理想的拥有对象构造函数和实例

在同一个类中声明的方法,但我似乎无法以任何其他方式有效地工作




我很感激任何建议。


- Stu

Hi all,

I am hoping that someone with some experience developing nTier apps can give
me some advice here.

I am writing an nTier web app that began with a Data Access Layer (DAL),
Business Logic Layer (BLL) and User Interface Layer (UIL).

The problem I found with this was circular referencing...

My objects would be defined in the BLL, so let''s say for example that I want
to instantiate a new BLL.Customer object in the UIL, and then run
Customer.AddCustomer() which would in turn pass the object into the DAL,
let''s call this method DAL.AddCustomer(BLL.Customer myCustomer) which would
insert into the DB.

The problem is that the BLL needs to reference the DAL and the DAL needs to
reference the BLL (to receive the custom business object), hence a circular
referencing error. I understand that I could turn this custom object into
some sort of generic object[] or collection and pass it then, or
alternatively pass the method field values one by one (not practical with
10+ values)

What I did was to create a 4th ''vertical'' layer which I called the ORL
(Object Reference Layer), the purpose of which is to allow all other layers
to reference the same objects so they can be passed between themselves
without issues. The drawback is that for this to work properly you need to
have the objects themselves defined in the ORL, but the methods defined
statically in the BLL.

My question is this...

Is this good programming?

Obviously it would be ideal to have the object constructor and instance
methods declared in the same class, but I can''t seem to get this to work
effectively any other way.

I would appreciate any advice.

- Stu

推荐答案

> ;问题是BLL需要引用DAL并且DAL需要
> The problem is that the BLL needs to reference the DAL and the DAL needs
来引用BLL(以接收自定义业务对象),因此
循环引用错误。
to
reference the BLL (to receive the custom business object), hence a
circular
referencing error.




这听起来不对。底层不应该引用顶层

层。所以DAL不应该引用BLL。


就像在网络协议中一样。 TCP建立在IP之上。如果IP引用了TCP属性,它会打破层分离。


我的建议是检查为什么DAL引用BLL并重新设计

DAL删除参考。


问候,

Wessel



That doesn''t sound right. The bottom layer shouldn''t reference the top
layer. So the DAL should not reference the BLL.

Just like in networking protocols. TCP is built on top of IP. It would
break the layer separation if IP referenced a TCP property.

My advise would be to examine why the DAL references the BLL and redesign
the DAL to remove the reference.

Greetings,
Wessel


谢谢你的答复Wessel。


DAL需要引用BLL的原因是因为它需要知道

关于它传递的对象。


例如,如果我在BLL中有一个Customer对象,并在DAL.UpdateCustomer(BLL.Customer myCustomer)中将其作为

参数传递, DAL需要知道''客户'是什么类型的对象,所以我需要从DAL层引用BLL

图层。


如果我没有这样做,我将无法通过''客户'作为参数

层之间,我宁愿需要逐个传递个人

属性,或者使用DAL已经知道的另一种类型的对象(即。对象阵列)


" Wessel Troost" <无***** @ like.the.sun>在消息中写道

news:op.sutprqbkf3yrl7@asbel ...
Thanks for your reply Wessel.

The reason the DAL needs to reference the BLL is because it need to know
about the object it''s being passed.

For example if I have a Customer object in the BLL and I pass it as a
parameter in DAL.UpdateCustomer(BLL.Customer myCustomer), the DAL needs to
know what sort of object a ''Customer'' is, and so i need to reference the BLL
layer from the DAL layer.

If i didn''t do this, i would not be able to pass ''Customer'' as a parameter
between layers, i would instead need to either pass the individual
properties one by one, or use another type of object that the DAL already
knows about (ie. object array)

"Wessel Troost" <no*****@like.the.sun> wrote in message
news:op.sutprqbkf3yrl7@asbel...
问题是BLL需要引用DAL和DAL需要
来引用BLL(以接收自定义业务对象),因此一个
循环引用错误。
The problem is that the BLL needs to reference the DAL and the DAL needs
to
reference the BLL (to receive the custom business object), hence a
circular
referencing error.



听起来不对。底层不应该引用顶层。所以DAL不应该引用BLL。

就像在网络协议中一样。 TCP建立在IP之上。如果IP引用TCP属性,它将打破层分离。

我的建议是检查为什么DAL引用BLL并重新设计DAL以删除引用。

问候,
Wessel



That doesn''t sound right. The bottom layer shouldn''t reference the top
layer. So the DAL should not reference the BLL.

Just like in networking protocols. TCP is built on top of IP. It would
break the layer separation if IP referenced a TCP property.

My advise would be to examine why the DAL references the BLL and redesign
the DAL to remove the reference.

Greetings,
Wessel



嗨Stuart,
Hi Stuart,
For例如,如果我在BLL中有一个Customer对象,并将其作为DAL.UpdateCustomer(BLL.Customer myCustomer)中的
参数传递,则DAL需要
知道什么类型的对象''客户'是,所以我需要从DAL层引用
BLL
图层。
For example if I have a Customer object in the BLL and I pass it as a
parameter in DAL.UpdateCustomer(BLL.Customer myCustomer), the DAL needs
to
know what sort of object a ''Customer'' is, and so i need to reference the
BLL
layer from the DAL layer.



好​​吧,那你为什么不呢?将客户的定义从BLL移到

DAL?无论如何,这似乎是一个适当的地方。


祝你好运,

Wessel


Well, so why don''t you move the definition of Customer from the BLL to the
DAL? That seems like a proper place to put it in any case.

Good luck,
Wessel


这篇关于通过nTier Web App传递Business Objects的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆