Documente Academic
Documente Profesional
Documente Cultură
Coding Style
Code Style
Source Code files One Namespace per file and one class per file.
Curly Braces On new line. Always use braces when optional.
e.g.
Bad Good
if (bIsEventNo) if (bIsEventNo)
doEvenCalculation() {
Else doEvenCalculation()
CallOddCalculation() }
Else
{
CallOddCalculation()
}
Indention Use tab with size 2. (with Insert spaces option set)
Comments Use // or ///. Avoid /* */
Do not put after code in same line.
Bad Good
Language Usage
Code Style
Native Data Types Use built-in C# native data types vs. .NET CTS types.
E.g. int vs. Int32
Enums Avoid changing default type.
Properties Never prefix with get or set.
Method Parameters Use a maximum of 7 parameters.
base and this Use only in constructors or within an override.
Trinary conditions Avoid.
for and foreach Prefer using for over foreach.
Conditionals Do not evaluate against true or false
No embedded assignment.
Avoid embedded method invocation.
Try/Catch/Finally Do not use exceptions for flow control.
Use throw; not throw e; for re-throwing.
Only catch what you can handle.
Events Always check for null before invoking.
Dispose() & Close() Always invoke them if offered.
Finalizes Avoid implementing one.
Never define a method named Finalize().
AssemblyVersion Increment manually.
ComVisibleAttribute Set to false for all assemblies.
Pascal Casing convention capitalizes the first character of each word (including acronyms over
two letters in length) as in the following examples.
PropertyDescriptor
HtmlTag
Camel Casing convention capitalizes the first character of each word except the
first word, as in the following examples.
propertyDescriptor
ioStream
htmlTag
Windows Controls:
Variables:
Scope Prefixes:
Form Standards
1. All forms should be centered (property 'StartPosition' set to 'CenterScreen').
2. All MDI child forms should be centered to MDI Main and smaller than MDI Main.
3. Minimize and Maximize buttons of all MDI child forms should be off (property 'MinimizeBox'
and 'MaximizeBox' set to 'False').
5. Appropriate spaces in the top, bottom, left and right corners of all the forms (Two pixels on top,
two on right and left corners and one on bottom).
8. Focus should be set on the right fields at the time of form load and after clearing the controls.
9. All controls should be properly aligned with appropriate spacing between them.
10. Font of form header label should be bold and color should be 'DarkBlue'.
11. Form header label should be followed by a group box with 'Height' set to 2 and 'Text' property
blank.
12. All label captions should be followed by a colon except the form header label.
13. Label captions of required fields should be followed by an asterisk (' * ') and the color of the
font should be 'Blue'.
14. Property 'MaxLength' of all text boxes should be set to the field value in the database.
15. Text fields which will remain disabled forever should be made 'Bold'.
16. The height of text boxes should be '20' and the width can be changeable.
17. The size of buttons should be '80, 22’ (with the exception that if the caption of a button isn't
getting accommodated then its width can be increased with all the other buttons of the same size
as that one).
18. Property ‘DropDownStyle’ of combo box should be set to ‘DropDownList’ (Unless there is an
exceptional case).
19. Label messages should be informative with Fonts 'Bold' and color 'Blue' for informative
messages and 'Red' for error messages.
20. Shortcut keys specified for the menu items and the buttons shouldn't be same.
21. Check verbiage (proper values are getting inserted and retrieved from the database).
22. Perform validations. Eg: - Numeric field should accept only integer values etc.
1. General
a. Followed file naming conventions for Form/Class/Modules?
b. Is the objective of Form/Class/Module defined?
c. Code indented properly?
6. Condition
a. Ignored case while comparing strings?
b. Used brackets for the query combined with “OR” logical operator?
c. Avoided multiple negations in the query?
7. IF-Else Construct
a. Avoided multiple If-else?
b. Does every condition meet?
c. Is condition readable and easily understandable?
8. Looping
a. Is loop definite?
b. Is condition readable and easily understandable?
c. Avoid repetitive calculative inside the loop?
10. Approach
a. Is business logic encapsulated in Class?
b. Is design modular?