isocpp / isocpp/CppCoreGuidelines
ES.9 lacks example
Nobody has claimed this yet.
- Dominant language
- CSS
- Stars
- 45.3k
- Forks
- 5.6k
- PR merge metrics
- No merged PRs in 30d
Description
"ES.9: Avoid ALL_CAPS names" has an "Example" section, but that should be labeled "Example, bad" to be consistent with other guidelines.
After renaming the existing example section I propose a positive example section to at least provide something like the following:
// example, better:
// no danger of name-clashes with ALL_CAPS macros:
// consider "enum class", though
enum Coord { North, NorthEast, NorthWest, South, SouthEast, SouthWest, East, West };
The lack of a positive example allows newcomers to come to the conclusion that instead of "SOME_NAME" they should use the same naming conventions for local variables and for global ones. While nowhere as bad as having an accidental macro substitution wreak havoc in a seemingly harmless peace of code, this could still lead to unintended hiding. Ex.:
namespace {
constexpr int SPECIAL_VALUE = 42; // bad, all caps
constexpr int specialValue = 42; // better
constexpr int c_specialValue = 42; // even better, visualizes global scope
}
My examples may not be the best, but I hope I've made my point...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Search the repository for the ES.9 guideline and inspect its existing Example section. Rename that section to “Example, bad,” add a clearly labeled positive example based on the issue, and verify that the rendered guideline distinguishes the bad and better naming examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100