Delegate is new feature in XOOPS Cube. It is unified callback procedure. Developer can use it as well as Function. And, it brings the possibility of exchanging. But, we plan to change the design of some classes about Delegate until XOOPS Cube 2.1 RC version. This plan triggers problems about the sample source code of this entry series.
Delegate is the feature of C#, D and some programing languages. It is like function pointers. As you know, programs have been using what is like function pointers since primeval age of a computer. It is jump to the address that is specified by address register.
Normally XOOPS Cube doesn’t need to define the procedure of callback in PHP. PHP has a function to callback, and programers can use some methods to callback. However, if a programer tries to implement plugin mechanism to all of his functions, he have to take much time and effort for programing and explaining.
He has to program loading plug-in files, checking functions and executing callback. See some XOOPS modules that has plugin mechanism. All means of these modules for callback are different. And, if he add on plug-in mechanism to his module that isn’t designed about callback, it becomes too large work.
Delegate solves these problems by unified callback procedure:
- A programer can change his function to Delegate as well as C#.
- A plug-in developer can learn XCube_Delegate mechanism only.
- Anybody doesn’t need to think about loading plug-in file. (Remember Preload mechanism)
A module developer can complete his program without callback at first. Next, he changes normal function to Delegte by the refactoring tool or manual. By this 2 steps, the exchangable module has just completed now!
If the core has the trackback function that is Delegate, user can replace it by other function of modules or 1 File Hackings. I can’t imagine XOOPS Cube without Delegate. Delegate is useful for core development, module development and customizing.