Steve Trefethen
Contact me Send mail to the author(s)
About Me View my LinkedIn profile

Powered by discountASP.NET
referal ID: sdtref
Why recommend discountASP.NET?

Archives
Statistics
Total Posts: 524
This Year: 26
This Month: 0
This Week: 1
Comments: 1835
Disclaimer
The posts on this weblog are provided �AS IS� with no warranties, and confer no rights. The opinions expressed herein are my own personal opinions and do not represent my employer�s view in any way.
# Tuesday, June 26, 2007
« Support Internet Radio's Day of Silence | Main | Using Google Maps from VCL sample applic... »

Delphi RTL and Language Wisdom

Tagged: Development

Tags:

It's Tuesday and following up my VCL list from yesterday, here my list for the RTL and Object Pascal language:

  • Learn to create your own TList descendants
  • Learn to write your own TCollection/TCollectionItem descendants
  • Use Format
  • Learn TThread then, understand TThread.Synchronize
  • Use TFileStream, TStringStream, TMemoryStream
  • Learn how to use the classes in SyncObjs.pas
  • Learn to call a function from a dynamically loaded DLL
  • Use exceptions
  • Learn when to use stdcall
  • Learn to use open array parameters
  • Use the *utils.pas units, DateUtils, StrUtils, MaskUtils, ConvUtils, VarUtils etc.
  • Learn the Math unit
  • Use SafeMM
  • Learn which exceptions the RTL throws
  • Use try...finally
  • Read the comments in SysUtils.pas
  • Call FindClose after calling FindFirst
  • Learn how to load packages dynamically
  • Use FindCmdLineSwitch
  • Just because it's not in Windows.pas doesn't mean it can't be called from Delphi
  • Learn function inlining
  • Be careful using "with"
  • Learn to use interfaces
  • Use dynamic arrays
  • Read the Language Reference manual
What am I missing?
Comments [3] # permalink Posted @ 9:34AM
Tuesday, June 26, 2007 12:28:50 PM (Pacific Daylight Time, UTC-07:00)
Where can I get SafeMM?
Sebastian Zierer
Tuesday, June 26, 2007 6:37:47 PM (Pacific Daylight Time, UTC-07:00)
First: always use FreeAndNil(X) instead of X.Free.

Second, the biggest single time-saver for me is my own TMonitoredObject class. It inherits from TObject, but adds a sequential ID number for each instance. If I $DEFINE DEBUG, the constructor and destructor each write a log entry indicating that they've been called, along with the actual class name and ID number. At the end of a program run, the unit that defines TMonitoredObject gives me a list of any objects that haven't been freed. It also tracks double-freeing, although that's less of an issue if you use FreeAndNil. Just insure you always use type TFoo = class(TMonitoredObject) instead of TFoo = class, and you're set. In one fell swoop, it makes memory leaks virtually impossible. I can stick a copy up somewhere if you want to see it, but it's pretty easy to produce just from that description.
Eric TF Bat
Wednesday, June 27, 2007 8:20:23 AM (Pacific Daylight Time, UTC-07:00)
Sebastian,
Ben Taylor did work on SafeMM though I can't find much about it on the web. I'll dig up what I have about it and get it posted. We use it here to help strictly with memory leak detection.
Comments are closed.