-
Notifications
You must be signed in to change notification settings - Fork 86
Coding Style
The article describes general coding style guidelines, which should be used for Atom code. These guidelines apply exclusively to C# source files.
As much existing AtomOS code as possible should be converted to this style. Make sure you mark your progress on Styling Issue.
- Every AtomOS source code file should include a file header like this:
/* * PROJECT: Atomix Development * LICENSE: BSD 3-Clause (LICENSE.md) * PURPOSE: File Description * PROGRAMMERS: Your Name (Your Email ID) */
You may add yourself to the PROGRAMMERS section of a file if you did a major contribution to it and could take responsibility for the whole file or a part of it.
- Using section of C# file should follow these guidelines
- No unused block.
- Internal namespace should come before external namespaces.
- Internal namespaces and external namespaces should be separated by a new line.
- Indent with tabs, don't use spaces!
- Editor Configuration File
Always put braces ({ and }) on their own lines.
One-line control clauses should not use braces.
Right:
if (condition) DoSomething(); if (condition) { DoSomething(); DoSomethingElse(); }
Wrong:
if (condition) { DoSomething(); } if (condition) { // note, one liner clause should not have braces DoSomething(); }
Naming convention should follow CamelCase.
Precede Boolean values with meaningful verbs like "is" and "did" if possible and if it fits the usage.
Right:
bool IsValid;
Wrong:
bool Valid;
Prefix Method Parameters with 'a' and non-public non-static class fields with 'm'.
- Space after if/while/do.
- No spacing after method name of identifier or array modifier.
Avoid line-wasting comments
Leave space after forward slash.
Right:
// Allocate memory for future heap manager // Find a suitable hole
Wrong:
//Allocate memory for future heap manager //Find a suitable hole