© Thomas Mailund 2017

Thomas Mailund, Advanced Object-Oriented Programming in R, 10.1007/978-1-4842-2919-4_3

3. Implementation Reuse

Thomas Mailund

(1)Aarhus N, Denmark

The easiest code to write is the code that is already written. If you can reuse existing code, it is always better than writing new code. You don’t have to spend time writing the code, and if the existing code has been around for a while there is a good chance that it is well tested and thus more likely to be correct than the new code you introduce. So your aim as a programmer should be to write as little new code as possible, paradoxical as it sounds.

The way to reuse code, however, is not to copy chunks of existing code from one place in your program and paste it into another. You ...

Get Advanced Object-Oriented Programming in R: Statistical Programming for Data Science, Analysis and Finance now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.