top of page

DRY- Don't repeat yourself

Any bit of code that you have written (or copy-pasted) twice, whether a single number or an entire method, should be subject to abstraction into a common symbol such that it is only defined or described in one place.

Obvious examples are “magic numbers” that might be reused repeatedly throughout the code; they should be placed in aptly named, discoverable constants.

Less obvious examples are routines, classes, or large passages of code that are only trivially different, usually spawned by a sweeping copy-paste with only tiny modifications being made to the new copy. These can often be abstracted or parametrized in a meaningful way to reduce the amount of code to maintain and reduce the chance for code divergence.


bottom of page