[Lazarus] IUnknown and reference counting
Hans-Peter Diettrich
DrDiettrich1 at aol.com
Thu Mar 21 18:16:12 CET 2013
Graeme Geldenhuys schrieb:
> On 2013-03-21 13:42, Michael Schnell wrote:
>>> * the ability to delegate the implementation of the interface to a
>>> different class (using the "implements" keyword)
>> To allow for a kind of multiple inheritance, I supple.
>
> No, not at all. It is to reuse existing code. You can have one class
> (say TObserver) that implements a IObserver interface, and that is all
> that that class does. You can then use the "implements" keyword in
> another class (eg: TMyObject), and delegate the IObserver implementation
> to the TObserver class. No need for the TMyObject class to re-implement
> all the methods that IObserver specifies.
>
> This concept is extremely handy if you implement something like
> Model-View-Controller (MVP) in Object Pascal and make use of Interfaces.
> Joanna Carter wrote some articles many years back on implementing MVP
> using Delphi. She used interfaces and delegation extensively (the most I
> have ever seen in any code). You can Google her name to find the articles.
"Using Delphi" is essential, the same won't work with FPC - when the
description of FPC "implements" is correct - because FPC then doesn't
allow to override selected methods of the delegate.
How should the IObserver know about the observed object?
DoDi
More information about the Lazarus
mailing list