Best Practices in
Scientific Computing

January 2015


Good programmers are
10X more productive than average

Good practices are
10X more productive than average

Rule 1

Write Programs for People,
not Computers

Rule 1a

A program should not require its readers to hold more than a handful of facts in memory at once.

Rule 1b

Make names consistent, distinctive, and meaningful.

Rule 1c

Make code style and formatting consistent.

Rule 2

Let the Computer Do the Work

Rule 2a

Make the computer repeat tasks.

Rule 2b

Save recent commands in a file for re-use.

Rule 2c

Use a build tool to automate workflows.

Rule 3

Make Incremental Changes

Rule 3a

Work in small steps with frequent feedback
and course correction.

Rule 3b

Use a version control system.

Rule 3c

Put everything that has been created manually
in version control.

Rule 4

Don't Repeat Yourself (or Others)

Rule 4a

Every piece of data must have
a single authoritative representation in the system.

Rule 4b

Modularize code rather than copying and pasting.

Rule 4c

Re-use code instead of rewriting it.

Rule 5

Plan for Mistakes

Note: improving quality increases productivity

Rule 5a

Add assertions to programs to check their operation.

Rule 5b

Use an off-the-shelf unit testing library.

Testing is Hard

Rule 5c

Turn bugs into test cases.

Test-Driven Development

Rule 5d

Use a symbolic debugger.

Rule 6

Optimize Software
Only After It Works Correctly

Rule 6a

Use a profiler to identify bottlenecks.

Rule 6b

Write code in the highest-level language possible.

Rule 7

Document Design and Purpose,
not Mechanics

Rule 7a

Document interfaces and reasons,
not implementations.

Rule 7b

Refactor code in preference to
explaining how it works.

Rule 7c

Embed the documentation for a piece of software
in that software.

Rule 8


Rule 8a

Use pre-merge code reviews.

Rule 8b

Use pair programming
when bringing someone new up to speed
and when tackling particularly tricky problems.

Rule 8c

Use an issue tracking tool.

Gosh, That's a Lot

One step at a time.

  1. Use text-based interfaces
  2. Turn history into scripts
  3. Put everything in version control
  4. Use test-driven development

Thank You

Greg Wilson, D. A. Aruliah, C. Titus Brown, Neil P. Chue Hong, Matt Davis, Richard T. Guy, Steven H.D. Haddock, Kathryn D. Huff, Ian M. Mitchell, Mark D. Plumbley, Ben Waugh, Ethan P. White, and Paul Wilson:

"Best Practices for Scientific Computing"
PLOS Biology, Jan. 2014,

Software Carpentry Logo