传递数据在应用程序的nTier [英] passing data in an ntier application

查看:116
本文介绍了传递数据在应用程序的nTier的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何传递数据层在N层应用程序?我已经制定了3种不同的方法。

How do you pass data to layers in an n-tier application? I have mapped out 3 different methods.

A)
通用的.NET对象的通用数据表,哈希表,通用的数据集,字符串,整数等..
然后使用数据集,以填补其被发送到UI层业务对象。

A) generic .net objects generic data tables, Hashtables, generic datasets, strings, ints etc... then using the datasets to fill your business objects which get sent to the UI layer.

<一个href=\"http://dabbleboard.com/draw?b=eiu165&i=26&c=54eef6f1ac01f03c85919518f4a24e798e57e133\">http://dabbleboard.com/draw?b=eiu165&i=26&c=54eef6f1ac01f03c85919518f4a24e798e57e133

临 - 的无需额外的层需要
CON - 的与业务层的通用数据集和表格的工作。

Pro- No extra layers needed Con- Have to work with Generic datasets and tables in the business layer

B)
使用实体层的其他层将引用。这一层将包含任强类型数据集或普通老式C对象。这些对象是主要是集装箱数据和很少的逻辑。这些将是发送到UI层中的相同对象。

B) using an entities layer that the other layers would reference. This layer would contain either strongly typed datasets or Plain Old C Objects. The objects would be mostly container data and very little logic. these would be the same objects sent to the UI layer.

<一个href=\"http://dabbleboard.com/draw?b=eiu165&i=6&c=d0c2b346894a96b12bd3867f630e474a2af098fa\">http://dabbleboard.com/draw?b=eiu165&i=6&c=d0c2b346894a96b12bd3867f630e474a2af098fa

临 - 的与所有层相同的类工作
CON - 的添加引用entities.dll所有图层

Pro- working with the same classes in all layers Con- adding a reference to entities.dll to all layers

C)
使用数据传输对象的数据访问层中定义(仅conatiner对象)。然后使用这些对象来填充它被发送到UI层的业务对象。

C) use data transfer objects (conatiner objects only) defined in the DataAccess Layer. then using those objects to fill business objects which get sent to the UI layer.

<一个href=\"http://dabbleboard.com/draw?b=eiu165&i=27&c=f886efa3f9d5eb4b45ddb02361c79cdcdaec0a9b\">http://dabbleboard.com/draw?b=eiu165&i=27&c=f886efa3f9d5eb4b45ddb02361c79cdcdaec0a9b

临 - 的业务层将不会有泛型类工作
CON - 的有两种类型的对象,并且你将不得不与传输对象来滋润业务对象

Pro- the business layer would not have to work with generic classes Con- working with two types of objects and you would have to hydrate the business objects with the transfer objects

我们在工作中有讨论,并希望看到社会的想法。我还添加了一个链接到dabbleboard。请复制并创造,而不是编辑。

谢谢

We had a discussion at work and wanted to see what the community thought. I also added a link to the dabbleboard. please copy and create instead of editing.
Thanks

推荐答案

如果您使用的是的分层的办法,所有层都在同一个进程空间(本质上)执行和意义有因此没有编组/序列化,我会用方法B.去创建您的实体在其程序中的各个方面依赖于一个独立的模块,以及夫妻。

If you're using a layered approach, meaning all layers are (essentially) executing in the same process space and there is therefore no marshalling/serialization, I'd go with approach B. Create a separate module for your entities upon which all aspects of your program depend, and couple to that.

不过,如果你使用的分层的方法,因为你的标题所暗示的,这意味着有被划掉的过程和/或网络边界,我建议你去与方法C.你又不是真的绕过的情况下,你传递的副本,让你得到任何好处耦合到同一个对象,像,比如说观察的场所,一个MVC的做法,反正都失去了。更好地在每一个层级定义数据API,而不是试图使用相同的类各地。

If, however, you're using a tiered approach as your title suggests, meaning there are process and/or network boundaries that are crossed, I'd suggest you go with approach C. You're not really passing instances around, you're passing copies, so any benefits you get to coupling to the same object, like observable options for, say, an MVC approach, are lost anyway. Better to define data APIs at every tier level than to try to use the same class all around.

这篇关于传递数据在应用程序的nTier的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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