.NET Dataset vs Business Object : Why the debate?

2019-04-17 06:54发布

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?

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)?

4条回答
Ridiculous、
2楼-- · 2019-04-17 07:21

"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).

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.

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.

Marc

查看更多
男人必须洒脱
3楼-- · 2019-04-17 07:32

why do people absolutly want "pure" Object model

Because you don't want your application to depend on the database schema

查看更多
疯言疯语
4楼-- · 2019-04-17 07:32

Well, all the reasons you give were the same as the academical reasons that were given for EJB in Java which was a mess in the past. So arent't people falling into another fashionable hype ?

As I read here: http://blogs.tedneward.com/2006/06/26/The+Vietnam+Of+Computer+Science.aspx

the promise is one thing, the reality is other thing.

Where is the proof upon the claims ?

Scientifically, Complexity is tight to the Concept of Entropy, you cannot reduce the inherent complexity of things, you can just move it somewhere else, so for me there is something fundamentally irational.

查看更多
SAY GOODBYE
5楼-- · 2019-04-17 07:40

Ted Newards is highly controversial because it seems to me that everybody is herding like in the old EJB days: nobody dared to say EJB suck until Rod Johnson gets out with Hibernate.

Now it seems nobody cares to say ORM frameworks like Hibernate, Entity Framework, etc. are too complex, because there isn't yet another Rod Johnson II maybe :)

You pretend that adding a new layer solves the problem, it's not always the case even theorcially, like adding more team members when a project becomes a mess because adding more programmers also mean add to coordination and communication problem.

And in practice, what it seems, is that the layers that should be independant at least from the GUI viewpoint, aren't really. I see many people struggle to do simple stuff in the GUI when they use an ORM.

查看更多
登录 后发表回答