1) Convert functions in KRAD files to Objects:
krad.ajax.js - KradAjax
krad.message.js - KradMessage
krad.utility.js - KradUtility
krad.validatate.js - KradValidate
krad.widget.js - KradWidgets
(Note krad.variables.js is already an Object).
2) A global variable will be created with an instance of each object:
This variable should be used whenever one of the KRAD methods are needed.
3) Refactor as we move along introducing properties in the objects and possibly breaking down in smaller objects
Note: We should also strive to follow the SRP (Single Responsibility Principal) for our methods. Each method does one task only. This will allow for only overriding what is necessary.
Suppose our KradMessage object had the following method:
In a custom application file (included through the View configuration), the method can simply be redefined:
Since all of the KRAD code is using the kradMessage variable, all calls will now invoke the custom application showAlert method.