Coding standards

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
 +
==Guidelines==
 +
 
Generally speaking
 
Generally speaking
  
Line 5: Line 7:
 
* Method names have all their words capitalized (as opposed to Java, which culturally uses camelCase).
 
* Method names have all their words capitalized (as opposed to Java, which culturally uses camelCase).
 
* Unless the classes are very trivial, there should be one class per file.
 
* Unless the classes are very trivial, there should be one class per file.
 +
* Please keep the code warning free, using #pragma only if absolutely necessary.  For instance
 +
 +
#pragma warning disable 0612
 +
            ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Script]              = "_script.txt";  // Not sure if we'll ever see this
 +
#pragma warning restore 0612
  
For instance.
+
==Example==
  
 
  public void WakeUp()
 
  public void WakeUp()

Revision as of 12:22, 12 July 2008

Guidelines

Generally speaking

  • We put curly brackets on separate lines and use 4 space tabs.
  • Tab themselves should be spaces, not actual hard tabs.
  • Method names have all their words capitalized (as opposed to Java, which culturally uses camelCase).
  • Unless the classes are very trivial, there should be one class per file.
  • Please keep the code warning free, using #pragma only if absolutely necessary. For instance
#pragma warning disable 0612
           ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Script]              = "_script.txt";   // Not sure if we'll ever see this
#pragma warning restore 0612

Example

public void WakeUp()
{
    if (tooTired)
    {
        Thread.Sleep(3600);
    }
}

Otherwise in general, just respect the conventions already being used in the file you're editing (which should often follow the standard C# coding guidelines).

Personal tools
General
About This Wiki