From 56418ac72a0a4237087ca155051ab0d72ef3dc0d Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Fri, 6 Jan 2017 03:30:10 -0500 Subject: [PATCH] Started documenting coding style used in glabels. --- CODING-STYLE.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 CODING-STYLE.md diff --git a/CODING-STYLE.md b/CODING-STYLE.md new file mode 100644 index 0000000..9bb334d --- /dev/null +++ b/CODING-STYLE.md @@ -0,0 +1,37 @@ +Tabs vs. Spaces +--------------- + +Tabs are only used at the beginning of a line, and only used to express indentation level. Spaces are used +for any other type of vertical alignment, e.g. aligning function arguments. This ensures that the code +displays correctly everywhere, regardless of the viewer's tab size, and does not inflict the viewer with my +choice of tab size (8 spaces). + +I use the emacs smart-tabs-mode to automatically enforce this. +See https://www.emacswiki.org/emacs/SmartTabs for more information. + + +Indentation Style +----------------- + +Glabels code uses the Allman (a.k.a "BSD Style") of code indentation. I.e. the brace associated with a +control statement is placed on the next line, indented to the same level as the control statement. +Statements within the braces are indented to the next level. + +``` +while ( condition ) +{ + something(); + somethingElse(); +} + +if ( condition2 ) +{ + handleCondition2(); +} +else +{ + somethingElse(); +} +``` + +See https://en.wikipedia.org/wiki/Indent_style#Allman_style for more information.