Colin Fraser asked:

> Any disadvantages using Interfaces???

Not really. The main issue is designing your classes so that you can
actually take advantage of interfaces, rather than deep inheritance.

> Any slower performance???

No. Delphi interfaces are actually implemented as pointers to a part of the
VMT of an actual object. The dispatching of an interface call is no slower
than dispatching a virtual methods, and faster than dispatching a dynamic
method. The only overhead you get is in extra calls to _AddRef and _Release
that Delphi does to handle the interfaces lifetimes. But that's only a
matter of a few tens of CPU cycles in the era of 1GHz+ CPU's.

> Anything to look out for???

Memory management. It becomes some what complicated when you start mixing
interfaced objects that support reference counting (and thus free them
selves when your finished with them), and objects that don't do reference
counting (like most of those in the VCL).

You get this a lot in Delphi code when you are considering providing
interfaced access to GUI components, because the components life time is
measured by its owners life time, eg. edit control on a form, but the
interfaced usage still makes reference counting calls and you can get into
situation where the object needs to be destroyed because its owner is being
destroyed, but existing interfaces still exist and need to remain valid.

Note that Delphi 6 is going to change this somewhat, because you will be
able to define interfaces that don't inherit from IUnknown. I'm not entirely
sure how this will change the design decisions that you make, but it will
definitely allow more control over your implementation.

Cheers, Max.


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to