ABSTRACT

This chapter describes some heuristics and techniques to help you write more easily maintainable and testable code. These ideas are commonplace for computer scientists and software engineers, but in the R community – where users are more likely to have a data analysis or statistics background – there isn’t enough discussion on how to write good code.1 If these ideas are new to you, read on. If not, skip to the package development chapters, and perhaps show this chapter to that colleague who writes the code that nobody wants to read.2

The principle of “Don’t repeat yourself” has been nicely expressed as follows: