-
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: Copyright (C) Atomix Development, Inc - All Rights Reserved * Unauthorized copying of this file, via any medium is * strictly prohibited Proprietary and confidential. * PURPOSE: --- * PROGRAMMERS: Aman Priyadarshi ([email protected]) */
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 4 spaces, don't use tabs!
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'.
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