Object with auto execute procedures

2019-07-25 16:15发布

问题:

Is there a way to create an object with auto execute procedures? For example if a variable within this object has changed a private procedure kicks in and starts to do something?

回答1:

The language offers no such functionality. You have to implement it yourself.

Typically that's done by hiding the variable as a private, or better a strict private, and then ensure that all access to the variable is routed through a property. Then you can take whatever action you need in the property setter method.