Method Spies |
|
What are Method Spies? | ||
Method Spies are additional sections of code inserted invisibly into existing methods. The code of the spy has full access to all variables of the method in which it is inserted – self, parameters, temporaries, instance variables etc – and hence can ‘spy’ on any aspect of it. In addition, spies can execute any valid code, from a simple self halt to sophisticated diagnostics. In addition , the code of a method spy can refer to the spy itself through the pseudo-variable thisSpy. Via thisSpy, the spy can maintain and interrogate information about itself and its activations. To facilitate this, the spy provides two variables – context and activationContext. context is a Dictionary which is global to all activations of the spy; activationContext is also a Dictionary, but a separate activationContext exists for each activation of the spy. All activationContexts are stored within the spy, and can be separately inspected.
|
|||
Advantages of method spies | |||
|
|||
© 2002 Solutions Software Ltd. |