Software Carpentry - How good are the Best Practices?

BEST PRACTICES TOP

Adapted by Istvan Albert from Software Carpentry Best Practices in Scientific Computing


Background

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 1.1: Keep it simple

Rule 1.2: Make names consistent, distinctive, and meaningful.

Rule 1.3: Make code style and formatting consistent.


Rule 2: Let the Computer Do the Work

Rule 2.1: Make the computer repeat tasks.

Rule 2.2: Save recent commands in a file for re-use.

Rule 2.3: Use a build tool to automate workflows.


Rule 3: Make Incremental Changes

Rule 3.1: Small steps with frequent feedback

Rule 3.2: Use a version control system.

Rule 3.3: Version control EVERYTHING


Rule 4: Don't Repeat Yourself (or Others)

Rule 4.1: There can be only one

Rule 4.2: Modularize code rather than copying and pasting.

Rule 4.3: Re-use code instead of rewriting it.


Rule 5: Plan for Mistakes

Note: improving quality increases productivity

Rule 5.1: Don't trust. Verify

Rule 5.2: Use an off-the-shelf unit testing library.

Testing is Hard

Rule 5.3: Turn bugs into test cases.

Test-Driven Development

Rule 5.4: Use a symbolic debugger.


Rule 6: Optimize Software Only After It Works Correctly

Rule 6.1: Use a profiler to identify bottlenecks.

Rule 6.2: Write code in the highest-level language possible.


Rule 7: Document Design and Purpose not Mechanics

Rule 7.1: Document interfaces and reasons not implementations.

Rule 7.2: Refactor code in preference to explaining how it works.

Rule 7.3: Embed the documentation for a piece of software in that software.


Rule 8: Collaborate

Rule 8.1: Use pre-merge code reviews.

Rule 8.2 Use pair programming

Rule 8.3: 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

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

Penn State • generated from bootcamp-central via pyblue