Aquí hi ha alguns trucs diversos que poden fer que l'escriptura de connectors sigui menys tediosa:
Si necessiteu el valor d'un paràmetre de la IGU en diversos llocs en el codi del connector, considereu assignar-la a una variable en JS, i utilitzant-la en lloc de recuperar-la una vegada i una altra amb getString()/getBoolean()/getList(). Això és més ràpid, més llegible i amb menys tecleig, tot alhora:
function calculate () {
var narm = ""; // na.rm=FALSE is the default in all functions below
if (getBoolean ("remove_nas")) {
$narm = ", na.rm=TRUE";
}
// ...
echo ("results$foo <- foo (x" + narm + ")\n");
echo ("results$bar <- bar (x" + narm + ")\n");
echo ("results$foobar <- foobar (x" + narm "\n");
// ...
}
La simple funció d'ajuda makeOption() pot facilitar l'omissió dels paràmetres que tenen el seu valor predeterminat, en molts casos:
function calculate () {
var options
//...
// This will do nothing, if VALUE is 0.95 (the default). Otherwise it will append ', conf.int=VALUE' to options.
options += makeOption ("conf.int", getString ("confint"), "0.95");
//...
}