Date added/modified: 20 Dec 1999
You might be wondering why data modules are used? Besides the conventional uses mentioned in various books on Delphi, I found it useful for the following type of stuff.
Suppose, I have many non-visual components like file open dialogs, tool images, etc. They are used in many forms in my application. Do I add them to all the forms? It doesn't make sense. Do I add it to the main form and then use them? Doesn't look clean. In this case, it is best to create a data module and add such stuff to it. Then, either let the data module be automatically created or create it in the FormCreate of the main form and destroy in the FormDestroy. Now, you can access those shared components all over by using the data module. What is more, I found it also useful to add many helper functions which add a slight variation to the use of those components. For example, I can set filters on file open dialogs, can do real checks of my own on file existence, etc.