From 0fe774dbdfce99efb5f60a89e6dba6bd709de556 Mon Sep 17 00:00:00 2001 From: tomcw Date: Thu, 12 Jan 2023 21:37:41 +0000 Subject: [PATCH] Coding Conventions: . Avoid global vars & provide getter/setter accessor functions. . Avoid C++11 empty initializer lists. (PR #634) --- docs/CodingConventions.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/CodingConventions.txt b/docs/CodingConventions.txt index 55ad15c6..fe60104d 100644 --- a/docs/CodingConventions.txt +++ b/docs/CodingConventions.txt @@ -2,6 +2,9 @@ Coding Conventions for AppleWin =============================== History: +v6 - 12-Jan-2023 (TC) +. Avoid global vars & provide getter/setter accessor functions. +. Avoid C++11 empty initializer lists. (PR#634) v5 - 03-Apr-2022 (TC) . #1072: Add a space after keywords. v4 - 05-Mar-2022 (TC) @@ -130,6 +133,10 @@ EG: Not: for(int i=0; i<10; i++) +2.9: Avoid global variables. + +If a free variable exists within a C++ file, then declare it static and provide getter & setter accessor functions. + ------------------------------------------------------------------------------- 3) Use of sprintf() etc. @@ -151,6 +158,13 @@ Use type deduction only if it makes the code clearer to readers who aren't famil or if it makes the code safer. Do not use it merely to avoid the inconvenience of writing an explicit type. (Ref: https://google.github.io/styleguide/cppguide.html#Type_deduction) +4.2: Avoid C++11 empty initializer lists + +This notation can be too obscure, compared to using regular initialization (for POD) or ctors (for classes). +EG, avoid this: + int var {}; + struct s {}; + ------------------------------------------------------------------------------- Appendix: Legacy Hungarian notation