[fpc-devel] Tests of observer feature [was: Considerations about observer]

luiz americo pereira camara luizmed at oi.com.br
Fri Nov 30 02:48:20 CET 2012


2012/11/29  <michael.vancanneyt at wisa.be>:
>
>
> On Thu, 29 Nov 2012, luiz americo pereira camara wrote:
>
>
> Yes. I still do not see how your example shows this ?
>
> Your wizard knows it can observe. It attaches itself to the frame.
> The code frame does not need to know the observing object ?

Yes, you are right in this wizard case the page owner would know it's
an observer.

[]
>> It can crash since not necessarily owner (e.g. a simple TForm) will
>> implements IFPObserver?
>
>
> Who takes the decision to observe or not ? The TForm, I assume.
> Somewhere the decision is made. In this location you will necessarily know
> who will do the observing, and you will know it has IFPObserver.

OK

>>
>> You would not be forced or induced to use an interface it would be
>> optional.
>
>
> Eh ? I would need to do a AttachObserver(MyObservingObject as IFPObserver)
> everywhere where I want to observe, instead of
> AttachObserver(MyObservingObject).
>
> That is hardly optional ?
>

It's the small cost i pointed elsewhere.
In the other hand makes the code contract (what AttachObserver
expects) clear in the declaration. Also improves compiler type check
This is a trade off. I see your reason to hides the interface.

>>
>> BTW: did you read my comment about observer method not being public?
>> By the currently implementation to attach a Observer to a TPersistent
>> the programmer is _forced_ to use an interface contradicting what you
>> said above.
>
>
> I already fixed that. I also fixed the sender problem. In my cases I always
> had (Sender=Self).
>

Thanks

Did you read the TGUID (not necessary) part?

>> I know what to expect when i see an IFPObserver property but not when
>> i see an TObject (although i can guess by the name).
>
>
> I am sorry, but I really still do not understand your problem with the
> interface.
>
> Contrary to what it may look like, it is not so that I am dead set against
> such a change. However, to me, your change presents a serious disadvantage.
> Therefore I expect you at least to show to me that there is a substantial
> need or benefit in this for all of us.
>
> Because till now I simply do not see the need or benefit...

In the program that i mentioned in other message there's a use case
for observer. I'll try to implement it and post the result here.

Luiz



More information about the fpc-devel mailing list