Talk:Generics Collections TObjectList (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Clarifying OwnsObject

1. Create has an optional parameter OwnsObject, which defaults to true. The example undermines that understanding by first omitting the optional param, and then setting the OwnsObject property explicitly, which, if anything, suggests that OwnsObject defaults to false.

Example would be better if written:

 { Set the OwnsObjects parameter to true--the List will free them automatically. }
  List := TObjectList<TNewObject>.Create(true);
  // List.OwnsObjects := true; // delete this line

2. A later comment, "Destructor should be called" suggests that either the programmer should do something, or that what the library does is in some doubt. Better would be: "The library will call the destructor for the owned object..."

The same general critique applies to other samples in the Generics Collections series.

Gwideman 18:13, 23 January 2012 (PST)


Thank you for your input! Your suggestions are being analyzed by our team. -- Denisa Tibeica