1 This document outlines the coding style that I try to use and sometimes fail at
7 This document is released into the public domain for use by
8 anyone who wishes for any reason, with no accreditation, payment, or
9 consultation necessary. That is, you're ALLOWED to use it for anything, but
10 I'd PREFER it if you asked me first.
15 This style can probably be used in c, c++, java, dart, or whatever with a little
16 modification, but it was made for D. Consider yourself warned, if you use it
21 SPACING AND WHITESPACE
23 Add spaces in between keywords (if, for, while, etc.) and parentheses. Do this:
33 Don't insert a space when doing an assert(0);
37 One space in between a variable and an assignment operator. Do this:
49 When you have a long chain of assignments, possibly auto-generated, you may use
50 tabs to align all the "="s together. If one of the variables touches the tab,
51 don't insert a tab, forcing yourself to indent everything else. Like so:
61 Put an open-curlybrace on the same line as the code delimeter. Put the
62 end-curlybrace on its own line; or, if there is another code delimiter that's
63 connected to the first one, put the end-brace on the same line. Do this:
67 } else if (condition) {
73 NEVER UNDER ANY CIRCUMSTANCES leave out the brace. NEVER do this:
88 For indentation purposes, only tabs should be used. For the purpose of
89 aligning already-indented text, only tabs should be used. For the purpose of
90 seperating various similar items on the same line, a single space should be
94 int[5] foo = [5, 7, 9];
95 int[18] bar = [7, 9, 11];
96 int[283947] baz = [5, 3, 2, 3, 9];
97 int[2] biz = [3, 4, 1, 2];
98 } catch (RangeError) {
102 Note that the character in between "baz" and "=" is a tab, NOT a space.