数据集与OOP [英] Datasets vs. OOP

查看:71
本文介绍了数据集与OOP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在.NET TV和Iam上看过ADO.NET简介及其数据集

现在想知道它是如何在现实世界的应用程序中实现/使用的。


我不相信会创建一个数据集并为其添加关系并且

等等应用程序中的每个表,这将是一个真正的混乱,这<
与OOP无关。


通常,会创建一个类Customer,一个类发票,职位,

文章等等。

但是如何使用数据集实现这一点?数据集和封装数据

+隐藏在类中的实现似乎与我相矛盾。


对不起我的愚蠢,但我没有找到解释这个的例子。 br />

-

cody


[免费软件,游戏和幽默]
www.deutronium.de.vu || www.deutronium.tk

解决方案



" cody" < PL ********** @ gmx.de>在消息中写道

新闻:%2 *************** @ TK2MSFTNGP12.phx.gbl ...

我''我看过ADO.NET简介及其在.NET TV和Iam上的数据集现在想知道它是如何在现实世界的应用程序中实现/使用的。

我不相信一个会创建一个数据集并为它添加关系
等等,对于应用程序中的每个表来说,这将是一个真正的混乱和
这与OOP无关。

通常,会创建一个类Customer,一个类发票,
位置,文章等。
但是如何使用数据集实现这一点?数据集和封装
数据+隐藏在类中的实现似乎与我相矛盾。

对不起我的愚蠢,但我没有找到解释这个的例子。

- -


[免费软件,游戏和幽默]
www.deutronium.de.vu || www.deutronium.tk



实际上,由于DataSet是ADO.NET层次结构中的一个类,因此它具有与OO相关的所有内容。

您在OO解决方案中使用一个或多个DataSet对象。你如何选择
你自己的类定义中的对象与DataSet对象交互

取决于你。

例如,如果创建一个您的Customer类的实例,对象的数据库可以从DataSet

对象中的表中的给定行设置,如果它有意义的话你的场景。

通过使用DataSet对象,你可以利用继承和封装的两个更突出的功能来封装。


Peter [MVP视觉开发者]

所有行业的杰克,无人掌握。


2004年5月10日星期一01:06:44 +0200,cody

< pl ************************* @ gmx &由Matchi.com提供回到GT;写道:

我不相信会创建一个数据集并为其添加关系,
等等应用程序中的每个表


表不在应用程序中,它们在DBMS中。

,这将是一个真正的混乱,这与OOP无关。


数据管理与OOP无关。

通常,会创建一个类Customer,一个类发票,职位,
文章和等等。


但这是一个大错。客户,发票,文章等应该是

表不是类。表和类是完全不同的。

但是如何使用数据集实现这一点?数据集和封装数据
+隐藏在类中的实现似乎与我相矛盾。




数据集不适用于此。它们用于将表格呈现给

用户。

问候

Alfredo


Cody,

Martin Fowler的书企业应用程序架构模式来自

Addison Wesley讨论何时使用数据集何时创建域

模型。 http://www.martinfowler.com/books.html#eaa


使用Typed DataSet或非类型化DataSet,是一种可行的面向对象

,用于在.NET中创建解决方案。除了更多

传统之外域对象(业务对象)接近。 Martin使用

术语表模块模式来指代使用数据集。


Martin的书中讨论了何时应该考虑使用数据集,以及

支持OO方法的各种模式(DataSet或Domain

object)方法。


例如我会考虑表格模块&表格数据网关方法如果

my" Domain objects"他们没有任何真正的逻辑。请参阅
http://www.martinfowler.com/eaaCatalog/tableModule .html &
http:// www。 martinfowler.com/eaaCatal...taGateway.html 模式


但是,如果我的域对象他们有很重要的逻辑,然后我会使用

领域模型和数据映射器方法。请参阅:
http://www.martinfowler.com/eaaCatalog/ domainModel.html &
http:// www .martinfowler.com / eaaCatalog / dataMapper.html 模式


注意:我的数据映射器将使用DataReader从

中读取一行数据库创建一个新的Domain对象,将行的信息传递给Domain对象的构造函数。


希望这有助于

Jay


" cody" < PL ********** @ gmx.de>在消息中写道

新闻:%2 *************** @ TK2MSFTNGP12.phx.gbl ...

我''我看过ADO.NET简介及其在.NET TV和Iam上的数据集现在想知道它是如何在现实世界的应用程序中实现/使用的。

我不相信一个会创建一个数据集并为它添加关系
等等,对于应用程序中的每个表来说,这将是一个真正的混乱和
这与OOP无关。

通常,会创建一个类Customer,一个类发票,
位置,文章等。
但是如何使用数据集实现这一点?数据集和封装
数据+隐藏在类中的实现似乎与我相矛盾。

对不起我的愚蠢,但我没有找到解释这个的例子。

- -


[免费软件,游戏和幽默]
www.deutronium.de.vu || www.deutronium.tk



I''ve seen an Introduction on ADO.NET with its Datasets on .NET TV and Iam
now wondering how it is realized/used in real world applications.

I don''t believe that one would create a dataset and add relations to it and
so on for every table in the application, this would be a real mess and this
has nothing to do with OOP.

Normally, would would create a class Customer, a class Invoices, Positions,
Articles and so on.
But how can this be realized using Datasets? Datasets and encapsulating data
+ hiding implemention in classes seems to be a contradiction to me.

Sorry for me stupidness but I found no example explaining this.

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk

解决方案


"cody" <pl*************************@gmx.de> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...

I''ve seen an Introduction on ADO.NET with its Datasets on .NET TV and Iam
now wondering how it is realized/used in real world applications.

I don''t believe that one would create a dataset and add relations to it and so on for every table in the application, this would be a real mess and this has nothing to do with OOP.

Normally, would would create a class Customer, a class Invoices, Positions, Articles and so on.
But how can this be realized using Datasets? Datasets and encapsulating data + hiding implemention in classes seems to be a contradiction to me.

Sorry for me stupidness but I found no example explaining this.

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk


Actually, as DataSet is a class in the ADO.NET hierarchy, it has everything
to do with OO.
You use one or more DataSet objects in your OO solution. How you choose to
have objects from your own class definitions interact with DataSet objects
is up to you.
For example, if create an instance of your Customer class, the datamembers
of your object could be set from a given row in a table within a DataSet
object, if it made sense to do so in your scenario.
By using DataSet objects, you''re taking advantage of inheritance and
encapsulation, two of the more prominent features of OO.

Peter [MVP Visual Developer]
Jack of all trades, master of none.


On Mon, 10 May 2004 01:06:44 +0200, "cody"
<pl*************************@gmx.de> wrote:

I don''t believe that one would create a dataset and add relations to it and
so on for every table in the application
Tables are not in the application, they are in the DBMS.
, this would be a real mess and this
has nothing to do with OOP.
Data management has nothing to do with OOP.
Normally, would would create a class Customer, a class Invoices, Positions,
Articles and so on.
But that is a blunder. Customers, Invoices, Articles, etc should be
tables not classes. Tables and classes are radically different.
But how can this be realized using Datasets? Datasets and encapsulating data
+ hiding implemention in classes seems to be a contradiction to me.



Datasets are not for that. They are for presenting the tables to the
users.
Regards
Alfredo


Cody,
Martin Fowler''s book "Patterns of Enterprise Application Architecture" from
Addison Wesley discusses when to use "Data Sets" and when to create a Domain
Model. http://www.martinfowler.com/books.html#eaa

Using either Typed DataSets or untyped DataSets, is a viable Object Oriented
approached to creating solutions in .NET. In addition to the more
"traditional" Domain Objects (business objects) approach to. Martin uses the
term Table Module pattern to refer to using a DataSet.

Martin''s book discusses when you should consider one over the other, plus
various patterns to support an OO approach with either (DataSet or Domain
object) approach.

For example I would consider a Table Module & Table Data Gateway approach if
my "Domain objects" did not have any real logic to them. See
http://www.martinfowler.com/eaaCatalog/tableModule.html &
http://www.martinfowler.com/eaaCatal...taGateway.html patterns

However if my "Domain Objects" had heavy logic to them, then I would use a
Domain Model and Data Mapper approach. See:
http://www.martinfowler.com/eaaCatalog/domainModel.html &
http://www.martinfowler.com/eaaCatalog/dataMapper.html patterns

Note: My Data Mappers would use a DataReader to read an row from the
database to create a new Domain object, passing the information for a row to
the constructor of the Domain object.

Hope this helps
Jay

"cody" <pl*************************@gmx.de> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...

I''ve seen an Introduction on ADO.NET with its Datasets on .NET TV and Iam
now wondering how it is realized/used in real world applications.

I don''t believe that one would create a dataset and add relations to it and so on for every table in the application, this would be a real mess and this has nothing to do with OOP.

Normally, would would create a class Customer, a class Invoices, Positions, Articles and so on.
But how can this be realized using Datasets? Datasets and encapsulating data + hiding implemention in classes seems to be a contradiction to me.

Sorry for me stupidness but I found no example explaining this.

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk



这篇关于数据集与OOP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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