On Fri, Oct 7, 2016 at 6:49 AM, Tony Whyman <tony.why...@mccallumwhyman.com> wrote: > The problem being referred to is the functionality described here: > > http://freepascal.org/docs-html/current/ref/refse44.html#x98-1200007.4 > > under the title "Interface delegation". The word "contained" does not appear > here. Maybe it should, but it doesn't. If TContainedObject does indeed solve > the problem then it would be useful to have it documented and, if so, for > interface delegation using a TInterfacedObject subclass to be at least > deprecated and may be even barred. > > The problem is that this is Rabbit Hole and it needs filling in otherwise > more will fall down it.
In a Facebook group, called Delphi developer, Michal Mutl says: Also you can implement TIntegerValue as TIntegerValue = class(TAggregatedObject, IValue) and you can really take advantage of ARC (no Free call in TMyApp Destroy impl). But then you must use it only as delegate, not standalone (ExecuteIntegerValue will fail). I didn't know about TContainedObject or TAggregatedObject... these classes solve the problem? Maybe. But not so fast. I've implemeted a Lib and I would like to say to my team: — If you needs to implements an IStream interface, you can use delegates, just use the TDataStream class. The team shouldn't know about the hierarchy; about how was implemented these classes. They can use TDataStream directly or as a contained object. But as I understood, we need to use TContainedObject or TAggregatedObject only in these "special cases" I didn't test yet. I will. But if I'm right, ie, if TDataStream is inherited from TContainedObject and, because that, I can not use TDataStream as a simple instance, without a "root" object... well, this design is wrong. If somebody says: "You should know these classes..." or "you should know what you're doing..." I will answer: this is not about OOP, just procedural. OOP is about encapsulation. If I need to see the class' code, this means that it was not well done. Best regards, Marcos Douglas _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal