Skip to content

CXX-3061 Move coding guidelines into a separate document #1168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 16, 2024

Conversation

eramongodb
Copy link
Contributor

@eramongodb eramongodb commented Jul 15, 2024

Summary

Resolves CXX-3061. Precursor changes to CXX-2745 concerning documentation of coding guidelines.

Docs changes will be required to make this page consistent with the new CONTRIBUTING.md file contents.

Contribution Guidelines

A large portion of the contents of the CONTRIBUTING.md document is very old and describe coding guidelines moreso than contribution guidelines. Furthermore, the instructions are both too detailed in some respects and too vague in others. Given the expected volume of coding guideline updates to come in light of CXX-2745 (Stable ABI), this PR proposes a small tidy-up of this file.

Given our current PR-based contribution, development, and review workflow, this PR proposes keeping the (external) contribution guidelines simple and to-the-point. Details may be addressed during code review and merge of the PR by the maintainer (who may edit the commit subject and description as-needed at time of merge).

Coding Guidelines

The extensive coding guidelines describing the architecture, interface design, and coding style is moved into a new and seperate etc/coding_guidelines.md file to avoid cluttering the external contribution guidelines. This file is not expected to require documentation changes (for repo only).

References to the MongoDB Server coding and style guidelines and the Google C++ Style Guide are removed: I do not believe we ever refer to these in practice. I believe there is enough existing code in the CXX Driver which may be used to inform and maintain consistency of style without relying on explicit guidelines.

The "Lifecycle Methods" section is removed due to dubious value.

The contents of the coding guidelines are expected to be updated in a followup PR as part of CXX-2745.

@eramongodb eramongodb requested a review from kevinAlbs July 15, 2024 18:26
@eramongodb eramongodb self-assigned this Jul 15, 2024
Copy link
Collaborator

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with minor comments addressed.


- License
- Include Guard (`#pragma once`)
- Header Prelude
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CXX-2258 intended to change the order to include the Header Prelude after System Headers and Driver Headers. Suggest updating ordering and the example below.

Suggestion can be ignored if this is expected to be revised with upcoming PRs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of this is expected to be overwritten by an upcoming PR (including the entire "general structure" guildeline), but regardless, our ClangFormat configuration automatically sorts headers by priority (for the most part) so this guideline can probably be removed. Replaced all header specs with "Include Directives" instead.


- Blank line at beginning and end of class declaration
- Public section up top / private at bottom
- Lifecycle methods first (see rules above)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Lifecycle methods first (see rules above)
- Lifecycle methods first

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworded to "special member functions".

@eramongodb eramongodb merged commit 2b85876 into mongodb:master Jul 16, 2024
1 check was pending
@eramongodb eramongodb deleted the cxx-guidelines branch July 16, 2024 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants