Peano 4
Coding conventions and IDEs

We follow the convention that the header files only hold the declarations, while the cpp files hold the actual implementations.

We kind of gave up on this convention in few particular places for speed, i.e. whenever a compiler should do inlining, i.e. remove function calls, but doesn't. If we found such places and suffered significantly in terms of performance, then we moved the implementation into the headers. We also use header-based implementations for template (the header implementation files then have the extension .cpph), but as soon as compilers do widely support templates that are not headers or we have moved functions over to the new C++ auto keyword, we'll move all into the implementation files.

I decided a while ago that all documentation should be in the headers if possible. Most documentation focuses on what a function does not how it does it. Therefore, the docu belongs to the declaration. If an implementation is so complicated or long that you need documentation within the source code to understand it, then the function needs to be simplified or split up.

Further to that, I try to make any source code, documentation, ... stick to a "80 characters per line" policy. Such files can be easily read with vi or less on the terminal on any computer.

Syntax Conventions

We mainly follow mainstream Java syntax conventions in Peano for historic reasons and as this is a real OO/C++ project. Some important principles are:

  • One file per class
  • Consistent naming conventions
  • Long, self-explaining names (no acronyms)
  • One subdirectory per namespace

Configuring Peano in Eclipse

You can integrate Peano straightforwardly into Eclipse. Clone the repository locally and invoke

libtoolize; aclocal;
autoconf; autoheader;
cp src/ .;
automake --add-missing

Open the Eclipse GUI and run the following steps:

  • Select New Project.
  • Select a C++ project. Older Eclipse versions want you to pick the mode Managed Build. Some wizard generations distinguish C from C/C++. I always pick the C/C++ version.
  • Locate the project at a remote directory (where you git deposits the clones).
  • Select GNU Autotools. The Empty Project is the right one to select.
  • You need only one target configuration. By default, Eclipse offers you to build Build and Debug. Disable the debug variant.

Some Eclipse wizards tend to overwrite Peano's file. If this is the case, replace the files through

git restore
git restore
git restore src/

and clean the project in Eclipse. Once you've done so, I recommend that you give the .gitignore file some special treatment:

git rm --cached file

Eclipse tends to insert the documentation folder to the ignored files once you enable the autotools pipeline. Every new commit now will add this ignore entry to the global repo, which is something we don't want to have.

Code Formatting

Recently (2023) a code formatting script has been added to incrementally add consistent formatting throughout the project. Under the hood, it uses clang-format for C++ code, and black for Python code.

Since the idea is to incrementally add consistent formatting throughout, the code script is set up to only format files that have been modified on your local branch to the main branch, p4. Ideally, the formatting script should be run on your local branch before you submit a merge request.

The usage is straightforward. The script can be found in Peano/ To format all files that differ from files on the main p4 branch, simply run


If you want to compare your local branch to a different branch than p4, you can specify that using the -b or --branch flag, e.g.

python3 --branch branch-I-want-to-merge-into
std::vector< GridControlEvent > merge(std::vector< GridControlEvent > events, const double Tolerance=0.1)
Merge set of refinement/coarsening commands.

Note that the format script detects potential files which might need formatting using git, therefore only files tracked by the git versioning will be considered.

If you prefer to run the formatting script on individual files only, you can specify them using the --files flag:

python3 --files myCppFile.cpp myCppHeaderFile.h

The --files flag doesn't check whether the files you provide are traced by git, and will try to format any files you provide. This can be used for instance to run the formatter on generated files.