-
Use an IDE that respects
.editorconfig
file (http://editorconfig.org/#download) and you won't have to worry about most of the stuff below 😏 -
Use tabs, not spaces, for indentation.
-
Private fields should be prefixed with an underscore (
_privateField
) and generally avoidthis
keyword. -
Use verbose variable names. Do not abbreviate.
-
Braces even for one liners:
RIGHT
if(condition) { doStuff(); }
WRONG
if(condition) doStuff();
-
Braces on a new line:
RIGHT
if(condition) { doStuff(); }
WRONG
if(condition){ doStuff(); }
-
Prefer good variable and method naming over comments. The exception is using comments for documentation purposes or complex algorithms.
Example IDE settings (captured from Xamarin)