TClientDataset 组件应该位于哪里?

发布于 2024-08-18 04:29:10 字数 193 浏览 3 评论 0原文

一些背景:我想开发一个桌面应用程序,用 SQL 数据库作为存储。一次只有一个用户连接到数据库。
为了使维护更容易,我想将 GUI 与 Busniss Logic 分开。因此,我想为每个对话框使用一个 DataModule(其中实现了 BL)。

我的问题: 插入 TClientDataset 组件的正确位置在哪里?直接在对话框中还是在数据模块中?

Some background: I want to develop a desktop application, with a SQL database as storage. There is only one user at one time connected to the database.
To make maintainance easier, I would like to seperate GUI from Busniss Logic. Thus, I thought using a DataModule (where the BL is implemented), for each Dialog.

My question:
Where is the proper place to insert a TClientDataset component? Directly in the Dialog or in the DataModule?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

乱了心跳 2024-08-25 04:29:10

就我个人而言,我总是将 TDataset 后代放在数据模块中。如果您在某个时候决定重新设计表单,您仍然可以使用数据集。在表单之间共享信息也变得更加容易。
一般来说,将 GUI 和数据分开!

Personaly, I place TDataset-descendants always in a datamodule. Should you, at some point, decide to redesign your forms, you still have your datasets at your disposal. Sharing information between forms is then easier as well.
In general, keep your GUI and data seperate!

蓝颜夕 2024-08-25 04:29:10

如果 TClientDataSet 不会同时被多个屏幕使用,则为了方便起见,将它们放在 DataModule 上是安全的。但是,当您有两个或更多屏幕访问同一个 TClientDataSet 时,您将会遇到问题,因为数据集只有一个光标,并且移动到一个屏幕上的另一条记录也会移动到其他屏幕上的另一条记录。在这种情况下:将 TClientDataset 放在使用该数据的屏幕上。连接仍然可以放在数据模块上,因为它由所有数据集共享。

If the TClientDataSet will not be used by more then one screen at the same time, it is safe to place them on a DataModule for convenience. However, when you have two or more screens accessing the same TClientDataSet you will have a problem since the dataset only has one cursor and moving to another record on one screen will also move to another record on the other screens. In that case: put the TClientDataset on the screens that use the data. The connection can still be put on the datamodule since it is shared by all datasets.

新人笑 2024-08-25 04:29:10

我会将数据集放入数据模块中。这样,您就可以不同表单中的多个视图指向同一个数据集,例如网格中的详细信息视图和列表,并且它们将始终自动同步 .
它还将数据与业务规则和用户界面与演示功能之间的分离正式化,从而更容易独立地更改业务规则或重新设计 UI强>.
如果您需要有多个表单实例来访问不同的数据,您始终可以实例化多个 DataModule,并将每个表单与其相关的表单挂钩。

I would put the DataSets in DataModules. That way, you can have multiple Views in different Forms pointing on the same DataSet, like a Details View and a List in a Grid, and they will always be in sync automatically.
It also formalizes the separation between Data with the business rules and User Interface with presentation features, making it easier to change the business rules or redesign the UI independently.
And if you need to have multiple instances of the Forms accessing different Data, you can always instantiate multiple DataModules and hook each Form to its relevant one.

聊慰 2024-08-25 04:29:10

数据模块中的数据集 - 但表单或框架上的数据源 - 一直对我来说效果很好。

Datasets in the Data Module - but DataSources on the form or frame - has always worked well for me.

菩提树下叶撕阳。 2024-08-25 04:29:10

datasnap 方式:

  • 拥有带有数据访问层和 TDatasetProvider 组件的 BL 数据模块,加上业务代码
  • 仅带有 TClientDatasets 的数据模块。

这样,如果您使用 DataSnap(或其他可以重用客户端数据集的 n 层技术)将实现更改为 n 层,则只需将 BL 数据模块移动到适当的层即可。

The datasnap way:

  • have BL datamodules with the data access layer and TDatasetProvider components, plus the business code
  • have datamodules just with the TClientDatasets.

This way if you change the implementation to a n-tier using DataSnap (or other n-tier technology where you can reuse the clientdatasets), you just have to move the BL datamodules to the appropriate tier.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文