1. Home
  2. Computing & Technology
  3. Delphi Programming

A warning on dynamically instantiating components

By , About.com Guide

2 of 10

Conflicting and Confusing Code

One problem with this code is that code readability suffers. The initial creation call where we pass "Self" as the owner conflicts with the Free method call in the Finally block.

Passing Self as the owner means that Self will destroy the TTable instance we just created. The last line of code (the call to "Free;") means the dynamically created TTable will not be destroyed by Self, but instead it will be destroyed programmatically.

This conflict in readability can increase the cost of maintaining the code.

Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Using VCL Components
  5. Run time VCL creation
  6. A warning on dynamically instantiating Delphi components

©2009 About.com, a part of The New York Times Company.

All rights reserved.