Skip to content

Latest commit

 

History

History
49 lines (25 loc) · 87.7 KB

File metadata and controls

49 lines (25 loc) · 87.7 KB

Coding Best Practices

PascalCase

For methods, functions, classes and namespaces.

camelCase

For variables.

Namespaces

Use them! Sensible naming, PascalCase.

If statements

Single line if statements must use '{ }'

French/Curly Braces { }

As above in the image, '{ }' brackets should be on a line of their own - this applies for classes, methods, for loops, while loops, foreach loops etc

OO Techniques

Basically - if you can abstract something that is likely to be used in a similar way elsewhere, abstract it.

Encapsulate classes. This provides specific entry points for classes and protects the inner workings (including data) of a class.

Design

Do not dive straight into coding a large system - take some time to at least do a class diagram and think through how the system will interact with other systems. See OO Techniques.

Class diagrams should be annotated where appropriate.

Descriptive variable names

Refrain from using one character variable names with the exception of variables used to iterate through a collection (i = 0 etc). Variable names should adequately describe their purpose.

Documentation

All classes and methods should have XML-documentation (type '///' above what you're documenting). Also, any code that may be unclear to others, does something especially complicated or would benefit from a comment(s) - comment it! See below for example (note the difference in readability between up to line 18 and after). Also see variable name specification.

See also

Microsoft's best practices (This document you're reading right now takes priority in the case of contradiction).