Create the Business Case, Stakeholder Analysis (S01 course participant, S02 Udemy coursists, S03 GitHub viewers), Project Plan and the milestone documents MIL-001 (project setup, 6 tasks) and MIL-002 (game implementation, 8 tasks) for the console Blackjack game. Register PP and MIL in the artifact registry, set the PO language to en, and link the synced Gitea milestones in the Gateway Schedule. Refs #1 Refs #2 Refs #3 Refs #4 Refs #5 Refs #6 Refs #7 Refs #8 Refs #9 Refs #10 Refs #11 Refs #12 Refs #13 Refs #14
2.9 KiB
2.9 KiB
C++ conventions
Standard base
ISO C++17 or later as set by the project (-std=c++20); the C++ Core
Guidelines are the rule source. C++ has no official naming style, so the
style below is used unless the project already has another (rule 1 of the
overall skill).
Naming
| Element | Convention | Example |
|---|---|---|
| Class, struct, enum, concept, type alias | PascalCase |
StayReader, Stay |
| Function, method, variable, parameter | snake_case |
read_stays(), byte_count |
| Data member (private) | snake_case with trailing underscore |
buffer_ |
| Struct public data member | snake_case, no underscore |
check_in |
Constant (constexpr, namespace-scope const) |
kPascalCase |
kMaxRetries |
| Enum class value | PascalCase |
Status::NotFound |
| Namespace | short snake_case; no using namespace in headers |
billing |
| Template parameter | PascalCase |
typename ItemT |
| Macro | UPPER_SNAKE with project prefix; avoid macros |
BILLING_ASSERT |
| Header / source file | snake_case.h / snake_case.cpp, same base name |
stay_reader.h |
| Header guard | #pragma once (or PROJECT_PATH_FILE_H) |
Formatting
clang-formatwith one checked-in config; 4 spaces (or the project's setting); braces on every control-flow body.- Include order: matching header, project headers, third party, standard library; each group sorted.
- One declaration per line; declare at first use, initialise with
{}.
Language rules
- Ownership: RAII everywhere. No owning raw pointers, no naked
new/delete; usestd::unique_ptrby default,std::shared_ptronly for real shared ownership, created withstd::make_unique/make_shared. - Follow the rule of zero; if you define one of destructor, copy or move, define or delete all five.
- Pass by
const&(large, read-only) or by value (small or sink); usestd::spanandstd::string_viewfor non-owning views,std::optionalfor "maybe",std::variantfor alternatives. constandconstexprby default; mark single-argument constructorsexplicit; markoverride/final;[[nodiscard]]on results that must be used.- Prefer algorithms and range-for over hand-written loops;
enum classover plainenum;nullptroverNULLor0;usingovertypedef. - No C-style casts; use
static_castand friends. No mutable global state. - Headers are self-contained and contain declarations, templates and
inlinedefinitions only.
Errors
Use exceptions for exceptional failures, or std::expected and error codes
where the project forbids exceptions; one choice per project. Destructors
never throw. Catch by const&; never catch (...) without rethrowing or
logging.
Tests
GoogleTest, Catch2 or doctest; run under sanitizers (address, undefined)
in at least one build.
Tooling
clang-format, clang-tidy with the Core Guidelines checks, compiler
warnings (-Wall -Wextra -Wpedantic), sanitizers.
Review with QC-CPP-001.