Trigger/hook system for classes =============================== Problem: ======== A class B might want to be informed about changes of objects of class A. As class A might have been designed before class B, we cannot simply use trigger methods of class A to implement the behavior desired by class B, as class A would not know what class B wants to be done. Furthermore, it would be bad design to implement such methods as methods of class A, as they concern class B. Solution: ========= Class A defines hooks for certain changes on its data. In its trigger methods, it causes execution of the methods registered with said hooks (by calling a GEAS function with the hook name). Example of usage: ================= [NOTE: The classes used in this example might not exist or might be implemented differently. This just an example!] In the employee class, there is a field that stores the employee's income. The employee class defines a hook that is to be called when the income field is changed. In a trigger method (onChange), this hook is called with the employee ID and the old and new income as parameters. The department class defines a field that stores the total income of all employees in that department. It defines a function that looks up the employee ID, checks the department and updates the total income field of the employee's department accordingly, and registers this function with the hook. Maintanability issues: ====================== [TODO: rewrite/rename this section] Allowing registering functions with hooks at run-time would raise several issues: - persistence: such registration might have to be stored between sessions. - deterministic behavior: it would be difficult to ensure deterministic behavior, as run-time registration might be unpredictable. Therefore, hooks and functions connected with them should be defined in the class definition store (GCD files, XML, database, etc.). Implementation: =============== [TODO: The syntax for describing hooks has yet to be defined.] GEOR issues: ============ GEOR has to track which hooks a class provides and which functions are connected with a hook. It has to maintain the latter whenever packages are added, updated, or removed. This might also happen at run-time. The above-mentioned will be requested by GEAS when executing hooks. GEAS issues: ============ GEAS has to cause execution of the registered functions whenever a hook is triggered.