https://github.com/hannorein/rebound
Revision 486c368aa6652649e4abae0e77669c1a5f8f46ba authored by Hanno Rein on 13 November 2023, 23:34:34 UTC, committed by Hanno Rein on 13 November 2023, 23:34:34 UTC
1 parent 4a39e0d
Raw File
Tip revision: 486c368aa6652649e4abae0e77669c1a5f8f46ba authored by Hanno Rein on 13 November 2023, 23:34:34 UTC
Updating version to 4.0.0
Tip revision: 486c368
style.txt
Style Guide
===========

This is a short source code style guide for REBOUND. It is not enforced in any way and only intended to be a suggestion.

Functions (c)
-------------

* All non-static functions have the prefix reb_
* All lower case
* Multiple words are connected with underscores
* "Sentences" should follow "noun_verb" rule, where "noun" is the object that gets operated on. For example: reb_simulation_create() and reb_simulation_free()
* All functions belonging to a specific module have a common prefix. For example: reb_integrator_whfast_kepler_step(). This might get long, but note that this is only really required for functions intended for general use. Internal functions can be static and do not need to include the prefix.

Variables (c)
-------------

* The function naming convention rules apply.
* The only public variables are in structs. Therefore, they do not have the reb_ prefix.
* As an exception to the lower case rule: the number of particle N is capitalized.
* Variables beginning with an underscore are not intended for general use.

Objects (python)
----------------

* First letter is capitalized, all other letters are lower case
* Same name as in corresponding c struct except reb_ prefix. For example struct reb_particle is Particle.
* Instance methods in python drop the reb_ prefix and the noun from the corresponding c function. For example reb_simulation_move_to_com() becomes Simulation.move_to_com().

Specific function names (c)
---------------------------

* "create" describes a method which both allocates memory for the struct and then initializes the object. For example: reb_simulation_create()
* "reset" describes a method which resets the struct to (more or less) its initial values such that it can be used as if a new object was created. For example: reb_integrator_ias15_reset().

Header files (c)
----------------

* All struct and function definitions that a user might need to access are in rebound.h.
* Structs and function definitions that are specific to one module and are only used internally within the rebound library are in the module header files. For example: integrator_whfast.h.

Indentation
-----------

* Four spaces are used both in c and python for indentation.
back to top