.NET数据集VS业务对象:为什么争论?为什么不将二者结合起来? [英] .NET Dataset vs Business Object : Why the debate? Why not combine the two?
问题描述
我读了评论辩论<一个href="http://web.archive.org/web/20110910021109/http://blogs.objectsharp.com/cs/blogs/barry/archive/2004/02/10/273.aspx"相对=nofollow>这里(的目前的直播现场,没有评论)。
I read a debate in the comments here (current live site, without comments).
为什么争论?数据集对我来说就像一个关系型数据库,对象是一个分层式的模式。为什么人们绝对要纯对象模型,而我们还在处理关系数据库,那么为什么不将二者结合起来?
Why the debate? A Dataset for me is like a relational database, an Object is a hierarchical-like model. Why do people absolutely want a "pure" Object model, whereas we still deal with relational databases, so why not combine the two?
和我们是否应该,是否有任何重量轻,COM prehensive框架,使我们能够做到这一点(不是一个沉重的猛犸象,像NHibernate的,其中有一个巨大的学习曲线)?
And if we should, is there any lightweight, comprehensive framework that allows us to do that (not a heavy mammoth, like NHibernate, which has a huge learning curve)?
推荐答案
纯粹的对象是一个更容易的工作,该类型的对象为您提供了智能感知和编译时类型检查。
"Pure objects" are a lot easier to work with, the typed object gives you intellisense and compile-time type checking.
裸数据集是非常繁琐和恼人一起工作 - 你需要知道的列名,也没有类型检查可能的,所以如果你键入了错误的列名,你的运气,也不会发现错误,直到运行时(是最差的情况)。
Bare datasets are very cumbersome and annoying to work with - you need to know the column names, there's no type checking possible, so if you mistype a column name, you're out of luck and won't discover the error until runtime (the worst possible scenario).
类型化数据集是在正确的方向迈出的一步,但东西,你的工作在你的.NET code的仍然稳居非常密切和严格到你的数据库的实现 - 而不是通常一件好事,因为任何改变在基础数据库中可能会影响到你的应用程序,所有的方式到你的用户界面,并引起了很大的改变是必要的。
Typed datasets are a step in the right direction, but the "things" you work with in your .NET code are still tied very closely and tightly to your database implementation - not typically a good thing, since any change in the underlying database might affect your app all the way up to your UI and cause a lot of changes being necessary.
使用ORM像NHibernate的可以让你更好的抽象和分离从逻辑业务模式数据库(物理存储层) - 只有在最简单的场景将那两个是完全相同的1:1的比赛,所以你需要某种两者之间的翻译或映射反正。
Using an ORM like NHibernate allows you to better abstract and decouple the database (physical storage) layer from your logical business model - only in the simplest of scenarios will those two be an exact 1:1 match, so you'll need some kind of "translation" or mapping between the two anyway.
所以,这一切的一切 - 使用类型化数据集可能是正确的为小型,简单的应用程序,但对于一个具有挑战性的,较大规模的,企业级的业务应用程序,我决不会建议耦合的业务对象模型如此紧密,紧密的数据库。
So all in all - using typed datasets might be okay for small, simple apps, but for a challenging, larger-scale, enterprise-level business app, I would never recommend coupling your business object model so closely and tightly to the database.
马克·
这篇关于.NET数据集VS业务对象:为什么争论?为什么不将二者结合起来?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!