Plain Text | 16 lines | 13 code | 3 blank | 0 comment | 0 complexity | dec5cb144c21ac502be0511c9ed01804 MD5 | raw file
1Signals are a way for communication between object using the 'observer' design pattern. 2 3Use it to inform another object when an object's state changes by emitting a signal. 4 5How to use: 6-source: emit a signal to zero, one or more objects that are interested in this signal. 7-connection: just tell which procedure to execute when this object emits this signal. Any number of connections may be made on a sigle signal. In this case, procedures are executed in registration order. If one of them registers a new procedure on a working signal, it will be executed next time the signal occurs. It's permitted to un-register a procedure which will not be called again if not already executed (useful for procedures who need not to be called anymore, it may un-register itself). 8-data: values of any type may be associated with signals or no data (two INTEGERs for example). 9 10Comments: 11-data is more useful when they are of some basic type (INTEGER, STRING...) 12-thanks to signals, objects may be designed more independently. 13-an object may connect two objects via signals, even if they don't know each other (ex: a:A may connect signal new_string from b:B to procedure io.put_string, OUTPUT_STREAM doesn't know B nor B knows OUTPUT_STREAM). 14-signals are a pure Eiffel design with full static inference type check. Safe ;-) 15-simplicity (self-gratification ;-): use of signals does not require extra classes to be written, nor extra-code. JUST DECLARE SIGNALS AND EMIT THEM, USERS ONLY HAVE TO CONNECT SIGNALS YOU DECLARED! 16-read this file twice, each sentence must be kept in mind.