Examples variously call the component component
or cmp
but there are so many references to the component
or event
or helper
in typical code that I'm thinking it's time to reserve the single letter names for these as follows.
(One precedent is Android's R class.)
Controller:
({
showHelpMessageIfInvalid : function(c, e, h) {
h.childOf(c).showHelpMessageIfInvalid();
},
checkValidity : function(c, e, h) {
var child = h.childOf(c);
if (typeof child.checkValidity === 'function') return child.checkValidity();
else return child.get("v.validity").valid;
},
focus : function(c, e, h) {
h.childOf(c).focus();
},
})
Helper:
({
childOf : function(c) {
return c.find(c.get("v.multi") ? "dualListbox" : "select");
},
})
Here is another example from an internal discussion about what the code looks like when a method is decomposed into calls to other methods:
// Apex or Java
void higher(String argument) {
lower1();
lower2(lower3(argument));
}
// Helper method with long names (that get in the way?)
higherLevel : function(component, event, helper) {
helper.lower1();
helper.lower2(helper.lower3(component.get(“v.argument")));
}
// Helper method with short names (that help?)
higherLevel : function(c, e, h) {
h.lower1();
h.lower2(h.lower3(c.get("v.argument"));
}
What naming convention have you adopted in your Lightning Components for these parameters?
c, e, h
and inside the helper methods instead of passing the the helper we can dovar h = this;
and again in the helper we can access with the same nameh
;