Kanade's Delphi Stuff
Delphi Tips, Sample code and Tools
Copyright © 1997-2004, Sanjay Kanade
 
  Tips and Tricks on Delphi
Please read the DISCLAIMER before you use any of the tips from this web site. Go to main index
  Delphi Tips: For the beginning programmers
Tip 72:  Constructors and destructors
(modified: 06 Feb 2004)


Tip 33:  Why use a data module?
(modified: 20 Dec 1999)


Tip 23:  How to make one or more Delphi units to keep your utility functions
(modified: 16 Feb 2001)


  72: Constructors and destructors
Date added/modified: 06 Feb 2004

In the constructor, the first call should be to inherited create. Then, and only then, initialize your member variables.

In destructor, the inherited call should be the last one in your code.

  33: Why use a data module?
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.

  23: How to make one or more Delphi units to keep your utility functions
Date added/modified: 16 Feb 2001

See this tip in the sample code area.



 

Copyright 1995-2004, Sanjay Kanade. All rights reserved.
All trademarks and copyrights belong to their respective owners.