Talk:Generics Collections TObjectStack (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 understanding that by first omitting the optional param, and then setting the OwnsObject property explicitly, which, if anything, suggests that the OwnsObject property defaults to false.

Example would be better if written:

 { Set the OwnsObjects parameter to true--the stack will free them automatically. }
 Stack := TObjectStack<TNewObject>.Create(true);
  // Stack.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:09, 23 January 2012 (PST)