ChasteGuides/BestPracticeGuide

Best practices for Chaste developers

This page enumerates some best practices that have developed over the lifetime of Chaste, and help to make all developers' lives happier. They are similar to ChasteStrategies, but less formal.

Writing new code

Much information on coding style can be found in the ChasteStrategies, in particular CodingStandardsStrategy and CodeStructureStrategy.

Two important features of Chaste code is that it should be well documented and well tested. We use  Doxygen to generate hyperlinked documentation for Chaste automatically. Remember to add Doxygen comments to all your member variables and methods, and make them as informative as possible without being overly verbose. The  Doxygen manual is a helpful resource for syntax, in particular the  list of special commands. When documenting a whole class, try to give some higher level information on how the class can be useful. Consider whether a tutorial might also be helpful.

The DoxygenCoverage nightly build will show up any missing documentation or incorrect syntax; see ChasteGuides/AutomatedBuildGuide#Doxygencoverage for more information.

Writing tests

All functionality in Chaste must be tested; see also the TestingStrategy. Writing good tests is an art, but well worth practising. A test suite will generally consist of many small unit tests that check specific methods, rather than one huge test.

One point to note is that tests shouldn't just cover the trivial case. Try to consider what 'corner' or 'edge' cases might arise, and check for those. If a numerical algorithm should have particular error or convergence properties, check this. You should also test that code throws appropriate exceptions for error conditions.

Tests must cover every line of Chaste source code wherever possible. This is checked by the Coverage nightly build - see ChasteGuides/AutomatedBuildGuide#Coverage.

Make sure that continuous tests are as short as possible, since these are run frequently, and will be killed if too long (see ChasteGuides/AutomatedBuildGuide#Testskilledoff). Longer tests, when required, should go in the Nightly or Weekly test packs.

Not annoying your fellow developers

Chaste is developed collaboratively. However, due to the nature of academic life, not all development on the Chaste trunk occurs in iterations, and so there are occasions when you may have to commit to trunk individually. When you do so, it is still important to consider your fellow developers. For example,

Keeping up with what's happening

The LatestNews wiki page is used to update other developers on changes that might affect their work, for example changes to an interface that mean user projects would have to be modified to match, or the addition of useful new functionality. This helps those who don't have time to view every commit made. Please keep it up-to-date, and keep track of changes.

Also, significant changes that should be highlighted when the next release is made should be recorded in ReleaseNotes. Note that you don't need to edit both LatestNews and ReleaseNotes for minor changes; the content will be copied across when a release is made.

Writing tutorials

Tutorials are special tests designed to help new developers get familiar with the code. They therefore need special care when being written!