stephens_coding_standards
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
stephens_coding_standards [2012/12/16 04:35] – external edit 127.0.0.1 | stephens_coding_standards [2017/01/01 20:05] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | <term YAGNI> | ||
- | |||
====== Stephen' | ====== Stephen' | ||
===== Commented Code ===== | ===== Commented Code ===== | ||
- | No commented code, unless there is a comment clearly explaining under what circumstances the code should be uncommented. The YAGNI principle should be kept in mind. If there are no circumstances in which the code should be uncommented, | + | No commented code, unless there is a comment clearly explaining under what circumstances the code should be uncommented. The < |
**Justification: | **Justification: | ||
Line 68: | Line 66: | ||
To get a visual margin guide in Visual Studio 2010, ensure the Productivity Power Tools extension is installed, right click the 130th column and select Guidelines -> Add Guidelines from the context menu. | To get a visual margin guide in Visual Studio 2010, ensure the Productivity Power Tools extension is installed, right click the 130th column and select Guidelines -> Add Guidelines from the context menu. | ||
+ | |||
+ | ===== Blank Lines ===== | ||
+ | |||
+ | Code shall not contain more than one blank line in a row. There' | ||
===== Unnecessary Parentheses ===== | ===== Unnecessary Parentheses ===== | ||
Line 73: | Line 75: | ||
Code shall not contain unnecessary parentheses. Developers are expected to be able to use [[http:// | Code shall not contain unnecessary parentheses. Developers are expected to be able to use [[http:// | ||
+ | ===== Pointless Boolean Expressions ===== | ||
+ | |||
+ | The following boolean expressions are pointless and are not allowed: | ||
+ | |||
+ | <code c#> | ||
+ | booleanExpression == true // Use booleanExpression | ||
+ | booleanExpression != true // Use !booleanExpression | ||
+ | booleanExpression == false // Use !booleanExpression | ||
+ | booleanExpression != false // Use booleanExpression | ||
+ | |||
+ | if (booleanExpression) | ||
+ | return true; | ||
+ | return false; | ||
+ | // Use return booleanExpression; | ||
+ | |||
+ | if (booleanExpression) | ||
+ | return false; | ||
+ | return true; | ||
+ | // Use return !booleanExpression; | ||
+ | </ | ||
+ | |||
+ | Developers are expected to know and understand how boolean expressions work, how to express them in the simplist form possible, and understand and use the '' | ||
===== String Comparisons ===== | ===== String Comparisons ===== | ||
Line 86: | Line 110: | ||
* To do a comparison like a human, use '' | * To do a comparison like a human, use '' | ||
* It is extremely unlikely that '' | * It is extremely unlikely that '' | ||
+ | |||
+ | ==== Machine or Human? WTF? ==== | ||
The German alphabet has the letter ' | The German alphabet has the letter ' | ||
Line 107: | Line 133: | ||
resource.fr-CA.resx file = CultureInfo.CurrentUICulture | resource.fr-CA.resx file = CultureInfo.CurrentUICulture | ||
</ | </ | ||
+ | |||
+ | ===== Switch Case ===== | ||
+ | |||
+ | * If a Switch Case is intended to cover **every** case, it must include a '' | ||
+ | * If a Switch Case is intended to only cover **some** cases, it must include a comment to that effect. | ||
+ | |||
+ | ===== Exceptions ===== | ||
+ | |||
+ | Exceptions shall not be ' | ||
+ | |||
+ | <code c#> | ||
+ | // Career limiting code: | ||
+ | catch (Exception ex) | ||
+ | { | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Thou shall not throw a **new** exception in a '' | ||
+ | |||
+ | <code c#> | ||
+ | // Career limiting code: | ||
+ | catch (Exception ex) | ||
+ | { | ||
+ | throw new Exception(" | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== Id ===== | ||
+ | |||
+ | The correct capitalisation of ' | ||
+ | |||
+ | ===== SQL ===== | ||
+ | |||
+ | ==== Capitalisation ==== | ||
+ | |||
+ | Keywords are upper cased ('' | ||
+ | |||
+ | Functions are upper cased ('' | ||
+ | |||
+ | Built in types are lower cased ('' | ||
+ | |||
+ | Variables, table aliases and column aliases are title cased. | ||
+ | |||
+ | The names of user database objects are title cased (tables, columns, views, stored procedures etc.) | ||
+ | |||
+ | ===== Web.config ===== | ||
+ | |||
+ | The ''< | ||
{{tag> | {{tag> | ||
stephens_coding_standards.1355632541.txt.gz · Last modified: 2017/01/01 19:53 (external edit)