是列表<>比ASP.Net中的UISet的DataSet好吗? [英] Is List<> better than DataSet for UI Layer in ASP.Net?

查看:138
本文介绍了是列表<>比ASP.Net中的UISet的DataSet好吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从数据访问层获取数据到我的业务层,然后准备在我的UI中使用。

I want to get data from my data access layer into my business layer, then prepare it for use in my UI.

所以我想知道:是最好通过 DataReader 读取我的数据,并使用它填充列表< BLClasses> 或填充 DataSet 并将DataSet发送到UI层。

So i wonder: is it better to read my data by DataReader and use it to fill a List<BLClasses> or to fill a DataSet and send the DataSet to UI Layer ??.

我对良好的性能和可扩展性感兴趣

I'm interested in good performance and scalability.

推荐答案

您的UI层应该远离您的数据访问策略 - 它不应该处理原始数据。因此,您的UI应该直接或通过服务层与域对象进行通信。

Your UI layer should be far-removed from your data access strategy - it shouldn't be dealing with raw data. Thus, your UI should communicate solely with your domain objects (directly or through a service layer).

然后,您可以让UI层创建所需的数据结构命令渲染。通过缓存策略可以减轻任何性能问题。

You can then have the UI layer create the data structures that it needs in order to render. Any performance concerns could be mitigated through a caching strategy.

这会影响代码的可读性,可测试性和可维护性,这些应该始终是任何长期和短期目标

This affects the readability, testability and maintainability of the code which should always be long- and short-term goals of any design.

我认为最理想的情况是你想看到以下一些内容:

I think ideally you'd want to see something along these lines:


 UI
 /|\
  |
SERVICE (? depending on the design)
 /|\
  |
DOMAIN
 /|\
  |
 DCO
 /|\
  |
 DAL

编辑:

另一方面,如果您正在构建一个非常直接的WebForms应用程序,那么您可能会放弃一些这样的复杂性,只需使用Visual Studio提供的设计器。然而,我发现应用程序经常发展到超越拖放界面的功能,最终不得不重构成更加分离的设计。

On the flip-side, if you're building a very straight-forward WebForms application, then you may be able to forgo some of this complexity and just use the designers provided by Visual Studio. I've found, however, that applications often evolve beyond the capabilities of the drag-and-drop interface and you end up having to refactor into a more separated design.

你总是需要知道你通过选择一个架构策略来获得/损失什么。如果你可以在没有测试的情况下(在边缘)生活,减少UI的可读性和更紧密地耦合到数据****颤抖的****,那么或许更直接的方法是为你。

You always need to know what you stand to gain/lose by choosing an architectural strategy. If you can live (on the edge) with no testing, reduced readability and tighter coupling of the UI to the data ****shudder****, then perhaps the more straight-forward approach is for you.

进一步阅读的一些链接

  • SOLID principles of OOD
  • Fowler's PoEE
  • MSDN: Patterns and Practices

这篇关于是列表&lt;&gt;比ASP.Net中的UISet的DataSet好吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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