C/C++ Code Style: update conventions for type & value naming #80

Open
Campbell Barton wants to merge 1 commits from ideasman42/blender-developer-docs:pr-enum-naming-convention into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.

Update enum naming conventions text based on discussion in:

Based this comment by Brecht which was generally agreed on:
blender/blender#99080 (comment)

Since the existing docs state enum names should be all upper case, I've updated the docs to note that pascal-case should be used for C++ style enum labels based on:
https://devtalk.blender.org/t/style-for-enumerator-values/35290

Update enum naming conventions text based on discussion in: Based this comment by Brecht which was generally agreed on: https://projects.blender.org/blender/blender/issues/99080#issuecomment-121610 Since the existing docs state enum names should be all upper case, I've updated the docs to note that pascal-case should be used for C++ style enum labels based on: https://devtalk.blender.org/t/style-for-enumerator-values/35290
Campbell Barton added 1 commit 2024-10-08 03:50:07 +02:00
Update enum naming conventions text.
Campbell Barton changed title from C/C++ Code Style for Enums to C/C++ Code Style: update conventions for type & value naming 2024-10-08 03:50:59 +02:00
Campbell Barton requested review from Sergey Sharybin 2024-10-08 03:51:08 +02:00
Campbell Barton requested review from Bastien Montagne 2024-10-08 03:51:17 +02:00
Bastien Montagne approved these changes 2024-10-08 11:15:02 +02:00

There is a missing resolution to the followup: https://devtalk.blender.org/t/style-for-enumerator-values/35290/15 (The part We do need to have a policy for abbreviations).

There is a missing resolution to the followup: https://devtalk.blender.org/t/style-for-enumerator-values/35290/15 (The part `We do need to have a policy for abbreviations`).

Regarding abbreviations, there are two different cases imho:

  • Abbreviation: Removing some letters of one or more words (like lib for library, or ctx for context). In common written text, these typically follow capitalization rules of the regular words.
  • Acronym: an abbreviation made by taking the first letter(s) of an expression or sentence (like VSE for Video Sequence Editor, BKE for Blender KErnel, DNA for... Definitely Not Acid??? ID for... Independent Data-block??? ). These are typically always written in all capitals.

So for C++ enum identifiers, I would propose to:

  • Follow Pascal Case for abbreviations in general, but keep all caps for acronyms.
  • Allow (recommend?) usage of the underscore separator _ around acronyms when it helps readability.

This could give identifiers like ID_MakeLocalInLib, ImageScaleInVSE etc.

Also CC @HooglyBoogly @JacquesLucke @JulianEisel @howardt

Regarding abbreviations, there are two different cases imho: * Abbreviation: Removing some letters of one or more words (like `lib` for `library`, or `ctx` for `context`). In common written text, these typically follow capitalization rules of the regular words. * Acronym: an abbreviation made by taking the first letter(s) of an expression or sentence (like `VSE` for `Video Sequence Editor`, `BKE` for `Blender KErnel`, `DNA` for... `Definitely Not Acid`??? `ID` for... `Independent Data-block`??? ). These are typically always written in all capitals. So for C++ enum identifiers, I would propose to: * Follow Pascal Case for abbreviations in general, but keep all caps for acronyms. * Allow (recommend?) usage of the underscore separator `_` around acronyms when it helps readability. This could give identifiers like `ID_MakeLocalInLib`, `ImageScaleInVSE` etc. Also CC @HooglyBoogly @JacquesLucke @JulianEisel @howardt
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u pr-enum-naming-convention:ideasman42-pr-enum-naming-convention
git checkout ideasman42-pr-enum-naming-convention
Sign in to join this conversation.
No Label
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-developer-docs#80
No description provided.