Icy Labs Style Guide

D Syntax

Types and Scoping

Use of 'auto'

auto myFoo = new Foo(); // new class instance
auto myBarString = "bar"; // literal
auto myBaz = Baz(); // struct OpCall

// Do not:
auto mySomething = getThing();

Nested Classes

Local Variables

Classes

Doing Work in Constructors

Default Constructors

Explicit Constructors

Structs vs Classes

Inheritance

Interfaces

Operator Overloading

Access Control

Declaration Order

Length of Methods

Naming

General Naming Rules

Filenames

Type Names

Variable Names

Constant Names

Method Names

Template Names

Interface Names

Module Names

Comments

Comment Style

File Comments

Class Comments

Method Comments

Variable Comments

int foo; // this represents the amount of fooage

Implementation Comments

// searches for a red needle
// amongst a collection of needles
foreach ( needle; otherNeedles ) {
   // looks at each needle in the collection of needles 'otherNeedles'

   if ( needle.isRed ) {
      // a red needle was found

      writefln( "Red needle Found!" );
   } else {
      // a red needles wasn't found, keep looking

      writefln( "Still looking!" );
   }
}

Punctuation, Spelling and Grammar

TODO comments

Formatting and Statements

Parenthesis and Horizontal Whitespace

void someMethod( int argument ) {

}

callSomeMethod( 42 );

int foo = ((6 * 8) - 5);

if ( condition ) {

}

Line Length

Non-ASCII Characters

Spaces vs Tabs

Method Declarations and Definitions

Calls to Methods

Conditionals

if ( condition ) {

}

Loops

while ( condition ) {


}
for ( init; condition; update ) {

}

for ( int i = 0; i != length; i++ ) {

}

Switch

Boolean Expressions

Return Values

Variable Initialisation

Class Format

Vertical Whitespace

Exceptions

StyleGuide (last edited 2010-06-19 00:52:17 by DavidCollien)