In all modern software projects which are worked on by a team, a unified coding style is used. The benefits of this are numerous:
- Readers of the code will not know who write which part (unless they go through the Git commit history),
- Readers of the code will waste time thinking or wondering about the sudden changes in coding style,
- We will not have people in the team disagree about which style is superior, because everyone will be using the same style.
- A unified way of making variable names means that it will obvious to a reader when something is a variable (member or otherwise).
What to do
a) Take a look at Clang Format. It's a tool which takes a specific code style (specified in a .clang-format file), and applies that to the file you pass in as the argument.
b) Choose a specific style to enforce: I think the Google Code Style is really good, with some minor modifications, such as having the indent width be 4 spaces instead of 2. You can specify what our specific style looks like using these options. In particular, we want BasedOnStyle: google, and IndentWidth to be 4.
Any other modifications that you think are reasonable, should probably be discussed on the group with the others.
d) Run clang-format on every file in the repository so far (excluding files in the submodules).
e) Implement a GitHub Action which will prevent PRs with incorrect formatting from being merged into the main line of work. You can use this existing Action as inspiration ;)
In all modern software projects which are worked on by a team, a unified coding style is used. The benefits of this are numerous:
What to do
a) Take a look at Clang Format. It's a tool which takes a specific code style (specified in a
.clang-formatfile), and applies that to the file you pass in as the argument.b) Choose a specific style to enforce: I think the Google Code Style is really good, with some minor modifications, such as having the indent width be 4 spaces instead of 2. You can specify what our specific style looks like using these options. In particular, we want
BasedOnStyle: google, andIndentWidthto be 4.Any other modifications that you think are reasonable, should probably be discussed on the group with the others.
d) Run
clang-formaton every file in the repository so far (excluding files in the submodules).e) Implement a GitHub Action which will prevent PRs with incorrect formatting from being merged into the main line of work. You can use this existing Action as inspiration ;)