In the course of studying biophysics using computer models, I spend a fair amount of time writing computer codes. One of the most important features of a useful code is its durability, and specifically, how easy it is to customize, reproduce, and duplicate.
Over time, I’ve found that the most durable codes have the least red text in them. Most text editors color strings and floats in a special color (red in vim, pink in gedit, green in sublime). These colors help you distinguish variables from constants. Here’s an example from an automacs extension module.
The telltale sign of an extensible code is the almost total lack of seemingly arbitrary strings or floats in the functions. These constants almost always require fine-tuning, membership in a parameter sweep, or further correction. A far-sighted programmer will remove these parameters to a settings file which can then be tuned, saved, and copied in an uncluttered way.
The code above is an example automacs procedure for creating a lipid bilayer. It does a fair job of removing all of the red parts, and wheverever possible, it uses standard names for the constants that remain. This particular procedure calls standardized functions which
To put it another way: the more we weave together the design with the tools, the harder it will be to debug, make changes, or extend the method to other use cases. This is only a design principle — code is infinitely malleable. The crucial bottleneck is typically the effort required to ask a new question. If the cost of further extensions is too high, then we might never use our old codes to test novel hypotheses. My claim that red-free codes are the most durable is just another way of saying that it is best to write modular codes. The more modular the code, the more interchangable and reusable it will be.
As a corollary, the best codes are also mostly bluish, that is, they contain a large number of concise, informative comments. The figure above has little red, but it could use far more comments if it hopes to stand the test of time.