[fpc-devel] Recent added support for Observer pattern in FCL
Luiz Americo Pereira Camara
luizmed at oi.com.br
Tue Aug 28 13:30:51 CEST 2012
Em 28/8/2012 04:50, michael.vancanneyt at wisa.be escreveu:
>
>
> On Mon, 27 Aug 2012, Luiz Americo Pereira Camara wrote:
>
>> I ask to change to a mechanism that could allow customizable
>> operations (more than one)
>
> That is why you have ooCustom.
>
>>
>>
>> I'm asking that because i have implemented a similar mechanism that
>> support operations like Load, ChildAdd, ChildDelete, ChildChange. I
>> believe that more developers are in the same situation,i.e., using
>> observer pattern to an action not handled by those 5 types. It would
>> be helpful to use the native implementation otherwise i will have to
>> keep(re-implement) the observer support over TPersistent.
>
> That's why you have ooCustom and Data at your disposal.
>
ooCustom is already used in TCollection if i remember correct.
If i use it for a TCollection descendant that uses ooCustom with a
record pointer i would get a conflict and a possible crash.
Why not let TFPObservedOperation as integer and define constants.
It could define a constant like ooUser = 32
Below ooUser is reserved for future default constants
Above ooUser could be added custom messages
This is how LCL messages works
Its both light and extensible
>
>> BTW:
>> The names of the TFPObservedOperation are not consistent:
>> ooChanged is in preterit while others not
>>
>> ooChanged does not has Item suffix
>
> It does not need one. The sender has changed, not an item in a list.
> The 'Item'-s are for when sender is a list, and an item is added to
> the list.
> (TList, TStringList, TCollection)
I did the remark because in TCollection is fired because a a change in a
Item. But is fine.
Any way the preterit question is still valid Changed - Added - Deleted
or Change - Add - Delete
Luiz
More information about the fpc-devel
mailing list