Skip to content
D. Fober edited this page Nov 8, 2017 · 1 revision

Coding guidelines


The libmusicxml architecture

The library provides a memory representation of a MusicXML file that is very close to the MusicXML format: a score is represented as a tree where each node is a class that corresponds to a MusicXML element. Classes are generated using templates parametrized with integers that are automatically generated from the dtds.

The memory representation supports the visitor design pattern as well as the standard C++ iterators.

For more details about the architecture and algorithms, you should refer to library global presentation.

The library source code is located in the src folder.

Coding rules

  • class names: use the upper camel case convention
  • method names: use the lower camel case convention
  • fields names: must start with f and use next the camel case convention
  • constants: must start with k and use next the camel case convention

Recommendations

  • Expose class fields and methods only when necessary. The public section of a class should reflect it's services only and not it's internal implementation. The protected section should reflect behaviors shared at inheritance level only. And otherwise, make everything private as much as possible.
  • Don't use the friend attribute
  • Use and abuse of the const keyword whenever possible.

Validation

The validation process is intended to verify that a modified library doesn't introduce undesired changes. The underlying idea is that the library output should remain the same from one version to another one. Of course and when correcting bugs or improving the library, changes may occur but must be carefully checked.

Validation tools are located in the validate folder. You must start to generate a set of reference files BEFORE making any change to the library:

> cd validate
> make

Output files are generated in a folder carrying the current version as name (e.g. 3.11). The version number if taken from the libmusicxmlversion.txt file that you can freely modify.

To validate a set of changes you must:

  1. change the version number in libmusicxmlversion.txt
  2. run make to generate new output files
  3. compare with the reference files:
    > make validate VERSION=x.xx
    (where x.xx is your reference folder name, e.g. 3.11).
  4. check any difference that you get on output.

Note for Windows

Validation is based on the 64 bits version of the library and tools. To copy the tools at the appropriate location, you must run

> make win64

from the validate folder each time you make changes to the library or tools.

Clone this wiki locally