Using Delphi data-aware components - pros and cons [closed] Using Delphi data-aware components - pros and cons [closed] oracle oracle

Using Delphi data-aware components - pros and cons [closed]


I've found that using the data-aware components results in an application with no clear distinction between business and UI logic.

This is fine for small projects but as they grow larger the code becomes less and less maintainable.

All the various bits of event code (and their interactions) can become a real nightmare to understand!

Invariably in such cases I've ditched data-aware components and have switched to a (hand-coded) MVC design.

This does require a lot of up-front coding effort but results (IMHO) in a project that is maintainable, extensible and debuggable.


Having tried both data-aware and non data-aware style of Delphi applications I'm back in the data-aware component camp these days. It takes a bit of work and discipline to correctly layer the code but it's still quicker than doing everything by hand using non data-aware controls.

A few of my tips for data-aware component usage are

  • Don't just rewrite FishFact on a larger scale. Put some thought into your design.

  • Don't use a TDataModule, use many TDataModules each responsible for just a small aspect of your applications data.

  • TDatasets belong on TDataModules, while TDataSources belong on TForms (unless used for master/detail relationships).

  • Use in-memory datasets such as the DataSnap TClientDataSet.

  • Your ClientDataSets don't have to mirror your database tables exactly. DataSnap allows you massage your data structures in memory so you can produce datasets tailored for specific purposes. Specifically you can do things like

    • Joining two or more tables into the one editable dataset

    • Denormalizing master detail table structures, can simplify your UI code sometimes.

    • Create in-memory only fields (like calculated fields but you can write to them also)

  • TClientDataSet nested tables are useful but not the only way to express master detail relationships. Sometimes it's better to do it the old way with two independent TClientDataSets joined through a TDataSource.


Take a look at ORM solutions.

It's a nice approach with multi-tier architecture. See ORM for DELPHI win32