13 Conclusion
13.1 Benefits of offensive programming
Neither exhaustive nor limitative list. Main benefits are
- Applicable to new and legacy code
- Code instrumentation at the required level, according to your needs. No obligation to comply completely or to instrument completely.
- Transient or persistent approach allow to deal with code you own and code you do not own.
- Evaluation modes eases incremental work. Offensive programming type_checking_enforcement mode is complimentary of standard R evaluation mode, not contesting with it.
- Usable at build time, at test time, and at run time wherever and whenever needed.
- Reusable test cases, immediately available to replay. No need to read manual pages to run a test case. No need to type or copy/paste code to replay a test
- Generate directly testthat test cases, at the scope of offensive programming instrumented code. See wyz.code.testthat
- Generate offensive programming random data sets for testing purpose wyz.code.metaTesting
- Generates R documentation from code, offensive programming instrumented or not. Using wyz.code.rdoc API allows to customize and industrialize R documentation generation process
- Has a smooth learning curve. It is quite simple and intuitive, both from a programming point of view and from an end-user point of view
- Matches your scope. It is usable at design, build, and run stages.
Most of all, offensive programming brings following value
- reduced code size, as many checks are no more necessary and shall no more be implemented
- higher developer’s productivity on R implementation, although earned time is varying greatly from function to function, depending of its complexity. I got more than 15% of time gain using offensive programming coding on several R package creations.
- Automated test case generation reduces greatly the burden of testthat content generation. Expect a productivity gain higher than 70% here.
- Documentation creation is now reduced in a great proportion, leaving just the review at your charge. Expect a productivity gain higher than 80% here.
- increased execution speed, due to reduced and simplified code. Again, many checks are no more necessary, and comparing, some traditional R code with offensive programming R code, will bring a clear value in favor of the second, as it tends not only to reduce the volume of code, but also to simplify your R code and to ease bug avoidance. The root cause of these two improvements is coming from type purity.
13.2 Concerns of offensive programming
Again a neither exhaustive, nor limitative list
Non standard evaluation is always tricky and difficult to understand and put correctly in action, due to the two evaluation paradigms that are different from traditional R logic. Offensive programming is to be used wherever R standard evaluation scheme appears too limited or too lazy.
The two extraneous evaluation paradigms might bring runtime performance penalty, especially if you compare with standard R evaluation. Indeed, doing so is unfair, as it is not comparing apple to apple. Offensive programming adds two more kind of checks to decide on result compliance, that are simply unknown from R standard evaluation scheme.
One piece of advice, be sure to have a clear idea of what you expect. In standard R, we are all used to get results without even asking ourselves any question about types, polymorphism, parameters and computed results. With offensive programming you must be able to answer clearly to such questions.
13.3 Your feedback is welcome
Your feedback about package usefulness, package usage, and package extensions is welcome, as any improvement suggestion.Share them, this will really help me.
I you wish to contribute to package development, just drop me an email.