Title: Message
if your're worried about freeing objects, then use interfaced objects. If you're worried about speed (don't be) object creation is hardly slow by any measure. if you are worried about easy to maintain code, re-use and scalability of design. don't use arrays and records. Every record type you create is just an object lacking encapsulation of business rules.
 
I guess it really comes down to being an OO developer or not.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Paul Heinz
Sent: Friday, 7 February 2003 4:14 p.m.
To: Multiple recipients of list delphi
Subject: RE: [DUG]: Delete a variable from a Dynamic Array

Kyley Harris wrote:
This is why you are better off using object such as TCollection and TCollection item. there is no delete from the middle. shift all the memory down and setlength minus one 
It all depends on your access pattern. For simple groups of  simple types, or records that you create, pass around a few places, and then discard, a dynamic array is much cheaper - one call to allocate/deallocate lots of entries - rather than lots of individual calls to New and Dispose and/or Create. They're also reference counted for you (copy on write) and Delphi takes care of all the memory management.
 
If order within the array is important and insertion/deletion in the middle is common (so you can't move a single entry and chop), their performance is O(N) so you're better of with a linked list or similar indirect collection which has OO(log N) or O(1) insert/delete behaviour.
 
TTFN,
  Paul.
 
 
 
 
 
 

Reply via email to