

In the first, the user does not use clearly understandable function names or parameters. However, there are certainly a few differences between these two chunks. In the above example, we have two chunks in Python that do a simple enough task of checking for leap years. Let’s look at an example of how code can be improved to be more easily understandable. What is clean code? Two examples of the functionality equivalent code in Python to check if a year is a leap year with the second iteration being written more “cleanly”. That is the ultimate goal of clean code – having the code understandable by someone who is not familiar with the language. While this book was written for a software developer using Java, the examples were easily to follow along because the code was well written. One of the more influential reads was the book by Robert Martin called Clean Code. Overtime, reading books on R, coding, and statistics, it became apparent that there are a set of best practices that should be followed when coding in ecology and evolution. Neither is trained as a computer programmer and each entered the field of ecology through surveying the natural environment. However, what good is that published code if it is illegible?Īlessandro Filazzola and Christopher Lortie are both field ecologists and computational biologists. That is why many journals, Methods in Ecology and Evolution included, encourage code publishing with manuscripts. Thus, computational reproducibility (i.e., the ability to recreate someone’s analysis and results) is just as important as experimental reproducibility. Code that is understandable is less likely to have errors, more easily reviewed by colleagues, and more easily replicated. Alessandro Filazzola & Christopher Lortie tell us about their new article ‘ A call for clean code to effectively communicate science‘, which provides a series of recommendations and a suite of tools that can be used to help support scientists to produce cleaner code.Ĭan you clearly understand the code that you have written? What about if you gave it to a colleague? Or a reviewer? Or even a future version of yourself? Writing code that is as legible as it is functional is not an easy task, but it has significant benefits.
