[Lazarus] IUnknown and reference counting
Sven Barth
pascaldragon at googlemail.com
Thu Mar 21 21:51:44 CET 2013
On 21.03.2013 21:40, Hans-Peter Diettrich wrote:
> Sven Barth schrieb:
>> On 21.03.2013 21:15, Hans-Peter Diettrich wrote:
>>> Sven Barth schrieb:
>>>
>>>> > Interface delegation is something different from multiple
>>>> inheritance. The interface implementor and the interfaced object then
>>>> have nothing in common, the methods of the implementor cannot access
>>>> elements of the interfaced object.
>>>>
>>>> But with only interfaces you inherit merely the syntactical
>>>> "interface" while with delegation you can also reuse an existing
>>>> implementation for that interface.
>>>
>>> Use an object (class instance) for the same purpose, and you don't have
>>> to write additional code as well.
>>
>> Interfaces are there to abstract away the implementation,
>
> No, that's only a side-effect.
In some sense you are right: Their main purpose is to provide a contract
between the implementor and the consumer so that they can communicate,
thus the abstraction is indeed only a side effect. See also:
http://en.wikipedia.org/wiki/Interface_%28object-oriented_programming%29
>> because you'll only have access to those methods that the interface
>> defines.
>
> You also have access only to the public methods of a class.
>
But the public methods can be a superset of the methods provided by the
interface or the interface methods could only be implemented in private.
Regards,
Sven
More information about the Lazarus
mailing list