使用Delphi的数据库开发的最佳实践是什么? [英] What are the best practices for database development with Delphi?

查看:207
本文介绍了使用Delphi的数据库开发的最佳实践是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  1. 如何有效地使用RAD方法(重用代码)。任何
    样本,现有库,基本
    crud生成器?

  2. 如何设计OOP方法?其中
    设计模式用于
    连接,抽象不同的
    引擎/ db访问层
    (bde-dbexpress-ado),基本CRUD
    操作。 >
  1. How can I use the RAD way productively (reusing code). Any samples, existing libraries, basic crud generators?
  2. How can I design the OOP way? Which design patterns to use for connection, abstracting different engines/db access layers (bde-dbexpress-ado), basic CRUD operations.


推荐答案

我有我自己的Delphi / MySQL框架,我不会共享它,但我可以描述我采取的方法:

I have my own Delphi/MySQL framework that lets me add 'new screens' very rapidly. I won't share it, but I can describe the approach I take:

我使用一个标签式界面与基于TFrame的层次结构。我创建一个选项卡并将一个TFrame链接到它。

I use a tabbed interface with a TFrame based hierarchy. I create a tab and link a TFrame into it.

我使用标准的mysql存储过程实现来处理所有的严重管道和并发控制。 CustomerSEL,CustomerGET,CustomerUPD,CustomerDEL等...

I take care of all the crud plumbing, and concurrency controls using a standard mysql stored procedure implementation. CustomerSEL, CustomerGET, CustomerUPD, CustomerDEL, etc...

我的主要表单实质上包含navbar面板和包含TPageControl的面板

My main form essentially contains navbar panel and a panel containing TPageControl

我的层次中的类的一个例子

An example of the classes in my hierarchy

TFrame
TMFrame - 我的派生,接口实现捕获OnShow,OnHide和一些其他细节

TFrame TMFrame - my derivation, with interface implementations capturing OnShow, OnHide, and some other particulars

- TWebBrowserFrame
--TDataAwareFrame
--TObjectEditFrame
--TCustomerEditFrame
--TOrderEditFrame
等...
--TObjectListFrame
--TCustomerListFrame

--TWebBrowserFrame --TDataAwareFrame --TObjectEditFrame --TCustomerEditFrame --TOrderEditFrame etc... --TObjectListFrame --TCustomerListFrame

等...

和一些对话框。

TDialog
TMDialog
--TDataAwareDialog
--TObjectEditDialog
- TContactEditDialog
etc ..
--TObjectSelectDialog
--TContactSelectDialog

TDialog TMDialog --TDataAwareDialog --TObjectEditDialog -- TContactEditDialog etc.. --TObjectSelectDialog --TContactSelectDialog

等...

当我添加一个新对象进行管理时,它可能是客户的新属性,假设我们要跟踪客户拥有的车辆。

When I add a new object to manage, it could be a new attribute of customers, let's say we want to track which vehicles a customer owns.

创建表CustomerVehicles
我运行我的特殊sproc生成器创建我的SEL,GET,UPD,DEL
测试这些...

create table CustomerVehicles I run my special sproc generator that creates my SEL, GET, UPD, DEL test those...

从基类派生我上面提到,放一些控件。将标签添加到TCustomerEdit。

Derive from the base classes I mentioned above, drop some controls. Add a tab to the TCustomerEdit.

Delphi始终将Dataset作为抽象层,通过DataSources将其公开到您的GUI。将数据集添加到客户数据模块,并注册。我的自己的自定义函数在我的派生数据模块类,TMDataModule

Delphi has always the Dataset as the abstract layer, expose this to your GUI via DataSources. Add the dataset to the customer data module, and "register it". My own custom function in my derived datamodule class, TMDataModule

安全控制类似地在框架中照顾。我'注册'组件,需要一个安全标志可见或启用。

Security control is similarly taken care of in the framework.. I 'Register' components that require a security flag to be visible or enabled.

我通常可以添加一个新对象,构建sprocs,在一小时内添加维护屏幕。

I can usually add a new object, build the sprocs, add the maintenance screens within an hour.

当然,这通常只是开始,通常当你添加东西,你使用它多于跟踪。如果这是一个车库应用程序,我们想添加车辆的客户带入车库,id它所以我们可以跟踪历史。

Of course, that is usually just the start, usually when you add something, you use it for more than tracking. If this a garage application, we want to add the vehicle the customer brought into the garage, id it so we can track the history. But even so, it is fast.

我已经尝试使用较新的开发工具向年轻人分包,他们从来不相信我,当我说我可以做这一切都是用Delphi快十倍!我可以在两个小时内无故障地做什么似乎需要两天,他们仍然有bug ...

I have tried subcontracting to younger guys using 'newer development tools', and they never seem to believe me when I say I can do this all ten times faster with Delphi! I can do in two hours bug-free what it seems to take them two days and they still have bugs...

请小心规划您的VFI!正如有人提到,如果你想改变你的一个父类的组件的名称,准备麻烦。你将需要打开和编辑层次结构中的每个孩子,即使你清洁DCU,你仍然可以有一些DFM地狱。我可以向你保证,这仍然是一个问题。

DO - Be careful planning your VFI! As someone mentioned, if you want to change the name of a component on one of your parent classes, be prepared for trouble. You will need to open and 'edit' each child in the hierarchy, even if you clean DCU you can still have some DFM hell. I can assure you in 2006 this is still a problem.

不要创建一个怪物数据模块

DON'T create one monster datamodule

把你的时间在前期的设计,重构后,你已经创造了一吨的家属可以是一个有趣的挑战,但一个噩梦,当你得到一些新的工作快速!

DO take your time in the upfront design, refactoring after you have created a ton of dependents can be a fun challenge, but a nightmare when you have to get something new working quickly!

这篇关于使用Delphi的数据库开发的最佳实践是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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