I'm Jeff-Relf.Me, in Seattle, Late 2023, born in Seattle, 1960. My Mouse/Keyboard Layout. C++ Coding Rules: 1. Random Evaluation Order: i = ++i + i++ ; i = i++ + 1 ; Array[ i ] = i++ ; Func( ++i, ++i ); Func( i = -1, i = -1 ); Func( i, i++ ); Precedence: ( Top First ) Operator ------------- ---------------------------------------------- VarDefinition [] -> . Unary Func() p++->x ; Latter is First: (++p)->x (char) -j !j ~j *p &j sizeof Multiplicative * / % Additive + - Shift << >> Relational < <= > >= Equality == != Bitwise AND & Bitwise XOR ^ Bitwise OR | Logical AND && Logical OR || Conditional Bool ? Ops, True : False Assignment Latter is First: += -= *= /= %= >>= <<= &= ^= |= Sequencer , Docs.MicroSoft.COM/EN-US/Cpp/C-Language/Precedence-And-Order-of-Evaluation 2. Use an ArmMounted 4K/UHD IPS Monitor for 380 columns of "Console" text. My (Custom) Console, My Editor, Visual Studio Community 2017, Win10. "OCR A", "MS Mincho", "Segoe UI Symbol", "DejaVu LGC Sans Mono" and "nSimSun" ( depending on the glyph ) are nice. 3. Create fewer/larger functions. Put everything in a single, large .CPP file -- don't create .H files. Sadly, I've failed to merge some of my .CPP files/apps because the required testing would be too expensive/painful; as a result, they're not as fresh/tested as they could be. 4. Minimize comments and WhiteSpace. When I see sparse code, with lots of whitespace and comments, I _immediately know the programmer is struggling. WhenAndOnlyWhen debugging, does lots of comments and WhiteSpace make sense. 5. When it looks nicer, use commas, not semicolons; " Cnt = Nibble = 0, Byte = -1, P = B " looks better. 6. A variable's declared type isn't always appropriate; so Type Cast. #define szStr (int)wcslen // Return the length of a Unicode string. #define Zero( X ) memset( & X, 0, sizeof X ) // Implicit cast to (void*). Zero( aStruct ); 7. Local, ShortTerm variables are nice. Like: wchar _T[999], *P = _T ; { LoopRow(3) { LoopCol(4) P += Str( P, L"( %d, %d )%s", Row, Col, Row == eRow ? L"\n" : L" " ); } } printf( _T ); Globals: #define LoopRow( N ) int Row = -1, eRow = ( N ) - 1 ; while ( ++Row <= eRow ) #define LoopCol( N ) int Col = -1, eCol = ( N ) - 1 ; while ( ++Col <= eCol ) #define Str swprintf typedef wchar_t wchar ; Output: ( 0, 0 ) ( 1, 0 ) ( 2, 0 ) ( 3, 0 ) ( 0, 1 ) ( 1, 1 ) ( 2, 1 ) ( 3, 1 ) ( 0, 2 ) ( 1, 2 ) ( 2, 2 ) ( 3, 2 ) 8. If everything ( but the top node ) were local, then you'd be spending all your time traversing trees, like an ant, instead of doing real work. So use Global Variables/Functions early and often. This, the common way, is ambiguous: if ( HandleEvents(1) ) ... Instead, use globals (below), like this: WaitForClick = 1, HandleEvents(); if ( Click ) ... Globals: int WaitForClick, Click ; void HandleEvents() { MSG Msg ; GetMsg: PeekMessage( &Msg, 0, 0, 0, PM_REMOVE ); Click = Msg.message == WM_LBUTTONDOWN ; // Handle system events, like WM_NCACTIVATE... Blah Blah. // When WaitForClick == 1, Exit if-and-only-if there's a Click: if ( Click || !WaitForClick ) { WaitForClick = 0 ; return ; } // Draw Stuff... Blah Blah. goto GetMsg ; } 9. InLine Conditionals ( Bool ? True() : False() ) are nice and concise. For example: inline int TheSmaller( int X, int Y ) { return X < Y ? X : Y ; } #define FlagTheNym \ Nym.hardRank ? L"Top" : Nym.Dropped ? L"Dropped" : Nym.Mad ? L"Mad" : Nym.Cool ? L"Cool" : L"Shifty" 10. Simplify Odd system calls, like this: wchar aString[999]; Str( aString, L"A 32 bit, unsigned Random Integer: %I64d", Rand32 ); Globals: typedef wchar_t wchar ; unsigned int uiRand ; #define Rand32 ( rand_s( &uiRand ), uiRand ) // Seeding is implicit. #define Str swprintf // Print to a Unicode string, "printf" style. 11. I set " warnings as errors "; all but the following warnings are "on": c4100: unreferenced parameter. Useful when debugging. c4101: unreferenced local variable. OK when debugging. c4127 conditional expression is constant. while(1) is OK. "if ( ComplexExpression, 1 )" is a good debugging technique. c4189: local variable is initialized but not referenced. Variables get commented out, at times, when debugging. With " warnings as errors ", you don't want it to stop the debuging. UnUsed variables are informative, and might be needed again, later. c4238 nonstandard extension used: class rvalue used as lvalue. Needed when a simple int is (randomly) defined as an overly convoluted/Byzantine class ( like ID2D1SolidColorBrush ). c4239 type conversion; C++ randomness. c4244 '=': conversion from 'int' to 'char', possible loss of data. c4302 conversion from a larger type to a smaller type. c4305 truncation from 'double' to 'float'. C4309 '=': truncation of constant value. c4310 cast truncates constant value. c4311 64-bit pointer truncation ( storing shorts in a pointer ). Implicit casting is cleaner/nicer. c4312 conversion from a smaller type to a larger type. c4430 missing type specifier - int assumed; more C++ randomness. c4456 declaration of 'P' hides previous local declaration. c4457 declaration of 'P' hides function parameter. c4458 declaration of 'a' hides class member. <D2D1helper.H> needs it, more randomness. c4459 declaration of 'P' hides global declaration. P ( a ShortTerm, local pointer ) is cleaner/nicer. c4474 'swprintf' : too many arguments passed for format string. A format string, passed to a macro, might have default (unused) arguments. c4508 'Func': function should return a value; 'void' assumed. "Func() {}" is cleaner/nicer than "void Func() {}". c4554 check operator precedence for possible error. Fewer parenthesis is cleaner/nicer; just know the precedence. Use: b = 1, b -= Hr - (int)Hr, b = min( HrsOffLn, b ) Not: b = min( HrsOffLn, ( 1 - ( b - ( Hr - (int)Hr ) ) ) ) c4702: UnReachable code. A tempory "return" is needed, at times, when debugging. With " warnings as errors ", you don't want it to stop the debuging. c4706 assignment within conditional expression. c4709 comma operator within array index expression. Often, it's cleaner/nicer to assign stuff in an expression; same for array indices, "R_[ i++, i %= 4 ]". c4838 conversion from 'int' to 'wchar' requires a narrowing conversion