Recent

Author Topic: DataModules General Question On Usage  (Read 1616 times)

Knipfty

  • Full Member
  • ***
  • Posts: 230
DataModules General Question On Usage
« on: July 25, 2012, 09:31:11 pm »
I'm guessing there is no right or wrong answer her but I'll give it a try.

I'm building app with about a dozen tables and about as many Edit/Entry forms.  Usually there is DBGrid based form that leads to an edit/entry form bia menu clicks.  Right now, I've all the Tables, Queries, and datasources to be local to each form.

I'm thinking of moving these DB Access components to a DataModule or perhaps multiple DMs.  What is a good practice?  One DM for the entire app or one for each form or something in between?  If I go with just one DM for the enitre app, do I add DB components to be shared where possible or simply map them to each form and keep adding them as I add more forms?

Thanks

Knipfty
32-bit Lazarus 1.0 FPC 2.6.0, 64-bit Win 7, Advantage DB 10.10

taazz

  • Hero Member
  • *****
  • Posts: 5365
Re: DataModules General Question On Usage
« Reply #1 on: July 25, 2012, 09:41:49 pm »
I always use one DM for each logical unit eg Customers. This way I create the datamodules and their forms as the end users selects them to be displayed avoiding to have all that data and objects in memory. Also you must keep in mind that in some cases some master/detail relationships must be re-defined for each unit avoiding conflicts between the various units them self eg selecting a customer phone type and the active employe phone type changes too.
also you must keep in mind that it would make it a bit difficult to use dataset events (eg onscroll) to refresh objects in the grid or edit form.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

 

TinyPortal © 2005-2018