Add coding style for LLMs.
This commit is contained in:
@@ -11,3 +11,68 @@
|
|||||||
- Aggressively isolate, split off, deduplicate and reuse code which can be made into common library code. Do the same with UI elements. Do this both when implementing new features and opportunistically while refactoring or changing old code/UI elements.
|
- Aggressively isolate, split off, deduplicate and reuse code which can be made into common library code. Do the same with UI elements. Do this both when implementing new features and opportunistically while refactoring or changing old code/UI elements.
|
||||||
- Names of files, functions, classes, abstractions, database fields, etc should be aimed at disambiguating purpose and function, rather than at brevity.
|
- Names of files, functions, classes, abstractions, database fields, etc should be aimed at disambiguating purpose and function, rather than at brevity.
|
||||||
- Any source or header file that includes a Boost header must include `<boostAsioLinkageFix.h>` first (at the top of the file, or immediately after the include guard in headers), before all other includes, so Boost.Asio is used as a non-header-only library correctly.
|
- Any source or header file that includes a Boost header must include `<boostAsioLinkageFix.h>` first (at the top of the file, or immediately after the include guard in headers), before all other includes, so Boost.Asio is used as a non-header-only library correctly.
|
||||||
|
|
||||||
|
## Style:
|
||||||
|
|
||||||
|
* Project uses 4-char-width tabs for indentation.
|
||||||
|
* UpperCamelCase for class/struct names, lowerCamelCase for var and member var
|
||||||
|
names; underscores_between_words for namespace names. No hungarian notation.
|
||||||
|
* Differentiate overshadowing local arg var names from class member var names
|
||||||
|
by prefixing local arg var names with underscore (_).
|
||||||
|
* Single-line blocks after a selection/iteration statement must always be
|
||||||
|
enclosed in braces, but you can choose whether opening brace is on same line,
|
||||||
|
versus whether you put both braces on same line. I.e:
|
||||||
|
```
|
||||||
|
if (...) {
|
||||||
|
// Acceptable
|
||||||
|
}
|
||||||
|
if (...)
|
||||||
|
{ /* Also acceptable */ }
|
||||||
|
if (...)
|
||||||
|
// But never do this anywhere.
|
||||||
|
```
|
||||||
|
* Multiline brace blocks always have opening brace on next line.
|
||||||
|
* Classes/structs:
|
||||||
|
```
|
||||||
|
class/struct MyClass
|
||||||
|
// Opening brace always on next line.
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void function();
|
||||||
|
|
||||||
|
/* Member vars always go at the bottom of the class.
|
||||||
|
* always put a visibility marker before member vars begin.
|
||||||
|
*/
|
||||||
|
public:
|
||||||
|
int memberVar1, memberVar2;
|
||||||
|
/* When a member var's value is agnostic of its construction signature,
|
||||||
|
* use assignment in the class def to reduce code duplication and error
|
||||||
|
* surface.
|
||||||
|
*/
|
||||||
|
int memberVarWhoseDefaultValIsAgnosticOfConstruction = AGNOSTIC_DEFAULT_VAL;
|
||||||
|
};
|
||||||
|
|
||||||
|
class/struct MyClass
|
||||||
|
// Base classes have tab after colon.
|
||||||
|
: public MyClassBase1, public MyClassBase2,
|
||||||
|
// Tabulation persisted when base classes spill onto multiple lines.
|
||||||
|
public MyClassBase3
|
||||||
|
{
|
||||||
|
};
|
||||||
|
```
|
||||||
|
* Constructors:
|
||||||
|
```
|
||||||
|
MyCtor()
|
||||||
|
// No tab after colon for member vars.
|
||||||
|
: memberVar1(...), memberVar2(...)
|
||||||
|
// If ctor body empty, just do braces together on their own line.
|
||||||
|
{}
|
||||||
|
|
||||||
|
MyCtor()
|
||||||
|
// Base classes have a tab after the colon.
|
||||||
|
: MyCtorBase1(...), MyCtorBase2(...),
|
||||||
|
// Base class tabulation continues for multi-line situations.
|
||||||
|
MyCtorBase3(...)
|
||||||
|
memberVar1(...), memberVar2(...)
|
||||||
|
{}
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user