Commit ea147f78 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

Add contribution guide

parent 108d80a8
# Code Style-Guide
This style-guide is intended for developers writing code for AMDiS, is not complete and probably not applied to all parts of the AMDiS code. Feel free to edit existing source files in order to fulfill the styles.
Parts of this convention are taken from well established style guides, like the *Google C++ Style Guide*.
## File naming conventions
Filenames should be mixed lower and upper case, starting with an uppercase letter. They should not include underscores or dashed. Use an uppercase letter to indicate a new subword. Sourcefiles should end in `.cpp` and header files should end in `.hpp`. In case you move the code of a template class to a separate file, included textually at the end of the corresponding header file, use the extensions `.inc.hpp`.
The name of a file should follow the name of the implemented class in this file.
Examples of valid filenames:
* `AdaptInstat.hpp`
* `AdaptInstat.cpp`
* `DOFVector.hpp`
* `DOFVector.cpp`
* `` (the implementation of the methods of the template class `DOFVector<T>`)
Do not use filenames that already exist in /usr/include or are stdandard C/C++ include files, such as `math.h` (remember that windows files-systems are case insensitive and thus, there is not difference between `math.h` and `Math.H`.)
## Generale file structure
Every header file should start with a copyright notice and an include guard `#pragma once`, where the text of the copyright notice is given in the file `tools/license.templ.txt` and can automatically by added, using the script files in the `tools` directory:
``` c++
// Software License for AMDiS2
// Copyright (c) 2015 Institute for Scientific Computing TU-Dresden
// All rights reserved.
// Authors: Simon Praetorius
// This file is part of the AMDiS2 Library
// see also the LICENSE file in the distribution.
#pragma once
After the include guard a list of include files can be added, see *Names and Order of Includes*.
### Names and Order of Includes
All of a project's header files should be listed as descendants of the project's source directory. The includes should be grouped following the rules:
* [class header file] (for source files that implement an interface specified in a header file)
* C system files.
* C++ system files.
* Other external libraries' header files.
* Your project's header files.
For better readability a comment above each group can be added. Within each section the includes should be ordered alphabetically. Project's header files should be surrounded by `"`, while external header files hould be surrounded by `<...>`.
For example, the includes in `io/VtkWriter.cpp` might look like this:
#include "io/VtkWriter.hpp"
// [open]mpi header
#include <mpi.h>
// std c++ headers
#include <cmath>
#include <fstream>
// ...
// boost headers
#include <boost/filesystem/convenience.hpp>
#include <boost/filesystem/operations.hpp>
// AMDiS headers
#include "AdaptInfo.hpp"
#include "DOFVector.hpp"
// ...
### Namespaces
All implementation should be put into the namespace `AMDiS`. When a namespace closes, a corresponding comment should be added to the closing brackets:
``` c++
namespace AMDiS
// ...
} // end namespace AMDiS
## Line length
Each line of text in your code should be at most 80 characters long.
* An #include statement with a long path may exceed 80 columns.
* A raw-string literal may have content that exceeds 80 characters.
* ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment