I recently had a chance to read “Best Practices for Scientific Computing” and was very impressed; the article was insightful and clearly written. How did I end up on an article with over ten authors you ask? Well, I’m new to the programming scene and and still trying to get my bearings. I figured familiarizing myself with best practices would be an excellent place to start!
The actual article is around five pages (tl;dr for many people) so I will summertime it below. If you feel so inclined, please read Best Practices for Scientific Computing in its entirety! Even if you don’t find the article useful, you may find the 67 references to other books and articles at the end valuable.
Let’s get started with best practices for programmers, shall we?
1. Write programs for people, not computers.
- A program should not require its readers to hold more than a handful of facts in memory at once.
- Names should be consistent, distinctive, and meaningful.
- Code style and formatting should be consistent.
- All aspects of software development should be broken down into tasks roughly one hour long.
2. Automate repetitive tasks.
- Rely on the computer to repeat tasks.
- Save recent commands in a file for re-use.
- Use a build tool to automate scientific workflows.
3. Use the computer to record history.
- Software tools should be used to track computational work automatically.
4. Make incremental changes.
- Work in small steps with frequent feedback and course correction.
5. Use version control.
- Use a version control system.
- Everything that has been created manually should be put in version control.
6. Don’t repeat yourself (or others).
- Every piece of data must have a single authoritative representation in the system.
- Code should be modularized (rather than copied and pasted).
- Re-use code instead of rewriting it.
7. Plan for mistakes.
- Add assertions to programs to check their operation.
- Use an off-the-shelf unit testing library.
- Use all available oracles when testing programs.
- Turn bugs into test cases.
- Use a symbolic debugger.
8. Optimize software only after it works correctly.
- Use a profiler to identify bottlenecks.
- Write code in the highest-level language possible.
9. Document design and purpose, not mechanics.
- Document interfaces and reasons (not implementations).
- Refactor code instead of explaining how it works.
- Embed the documentation for a piece of software in that software.
- Use pre-merge code reviews.
- Use pair programming when bringing someone new up to speed and when tackling particularly tricky problems.
Seems like a great list to me! The only thing I would add to this list, which I’ve found in other articles I’ve read on the topic, is maintain and update older code.
What best practice would you add to this list (if any)? Please discuss in the comments below. Once you’ve done that, be sure to signup for a SmartFile for Developers account so you can put these best practices into action! (It’s free and has more features than Amazon S3 and Rackspace Cloud Files!)
Are you a developer who needs an API based file storage system?
|Free Tier Storage||100 GB||5 GB||None|
|Free Tier Transfer||200 GB||15 GB||None|
|Free Tier API Requests||Unlimited||20,000||None|
|File Size Limit||None||5 TB||5 GB|
|Inherit FTP Access||Yes||No||No|