On 07/10/2016 18:33 μμ, Marcos Douglas wrote:
We don't need "clean up properly" instances that is interface-based.
If this solve the problem for contained objects, I'll do it!
BUT, if I do this I can forget all about TContainedObject or
TAggregatedObject? If I can't, this not make sense.
OK this needs a bit more information.
The interface variable is only a half measure. It assumes and expects
that the container (the object that has a delegation) will always get
destroyed after all references to the delegated interface are released.
It does not check for it and it leaves everything to the programmer. If
the contained interface needs the container to function properly then a
number of of exception will be raised as soon as the container gets freed.
The TContainedObject on the other hand makes sure that the container can
not be destroy as long as there are references on the contained
interface which is a much safer solution.
I have used both with success in the past I still prefer the
TContainedObject approach for this little extra piece of mind that it
provides me.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal