Skip to content
Mikhail Panko edited this page Jan 17, 2014 · 56 revisions

Motivation

This wiki is not intended for teaching any particular language, entry level programming concepts, or numerical recipes for scientific programming. There are many other excellent resources on these topics. However, there is not much literature on more advanced programming concepts for scientists, especially related to maintaining and growing large code bases. The motivation of the wiki is to address that gap by sharing experiences which worked for scientists.

Major challenges for large coding projects:

  • Ability to understand and remember code when project becomes large
  • Ability to expand functionality with ease
  • Making code understandable and usable by others

Useful hypothetical test: will you be able to easily understand, use, and expand your code if you don’t touch it for a year?

A useful way to approach scientific programming is by thinking in terms of various programming modes. Most scientific programmers concentrate on prototyping and optimizing modes, while software engineers - on maintaining, sharing, and standardizing ones. When coding projects are large, maintaining mode is much more efficient than the prototyping one, so it is beneficial for scientists to learn and apply corresponding techniques. Occasionally, scientists would like to share their code with other researchers. Then sharing and standardizing modes come into play and require their own techniques.

General tip: don’t spend a lot of time figuring something out on your own if you know of someone who can explain the answer to you. Often there are community-accepted solutions to problems that are difficult to find online but that someone experienced with the programming language or field would find obvious. Know who you can go to for help (and return the favor).

Basic advice

Languages

Select a good language for scientific programming. Different languages have different strengths and weaknesses. Your specific task would suggest the best tool. Choose wisely. Here are several options successfully used by many scientists:

Make sure to use a smart editor with code highlighting and auto-completion.

Text formatting / Commenting

Variables / Data types

Data, files and folders hierarchy

Advanced advice

Object-oriented programming

In software engineering the most common approach to fight code complexity is object-oriented programming. It is well-suited for most large software projects but can have disadvantages for some scientific programming applications. It is good to know differences between OOP and good modular programming and choose an approach suitable for your needs. Here is a wiki section going into the details of the issue:

OOP in scientific programming

Functions / Modularity

Debugging / Testing

Version Control / Collaboration

Results

Packages / Libraries

Do not "reinvent the wheel". Aggressively search for and recycle other people’s code.

Language specific best practices

Code examples

Code examples are in the repository.

Non-coding tips for PhD students

Other resources for best practices

Clone this wiki locally