[RkWard-devel] Code generated for "multi action" plugins
Thomas Friedrichsmeier
thomas.friedrichsmeier at ruhr-uni-bochum.de
Thu Jan 4 00:55:43 UTC 2007
Hi!
While reviewing some plugins, I came across an issue that we should probably
have a policy for, but currently don't:
Many plugins *can* do more than one thing. E.g. the descriptive statistics
plugins will compute (among other things) either the mean, or the median, or
both.
Currently the code generated for that is something like:
rk.temp.options <- list (domean=1, domedian=0)
for (...) {
if (rk.temp.options$domean) rk.temp.results$mean[i] <- ...
if (rk.temp.options$domedian) rk.temp.results$median[i] <- ...
}
...
This approach has the advantage, that a user could copy the entire code
snippet, and simply change the "domedian" option to 1 to run the same
calculation including the median.
However, another approach is to only generate code for the chosen options.
I.e., if mean is selected, but not median, only the following would be
generated:
for (...) {
rk.temp.results$mean[i] <- ...
}
...
While if both are selected,
for (...) {
rk.temp.results$mean[i] <- ...
rk.temp.results$median[i] <- ...
}
...
would be generated. This second approach clearly has the advantage of keeping
the generated code shorter, and more readable (at the cost of making the
required logic to generate the code slightly more complex, but this would not
be user visible).
While writing this, I'm inclined to think the second approach is more elegant
overall, and should be preferred. Still, the first approach is more prevalent
in current plugins, and does have one advantage mentioned above. What do you
think, which style we should favor in rkward?
Regards
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/rkward-devel/attachments/20070104/cff0c7a1/attachment.sig>
More information about the Rkward-devel
mailing list