Space vs Tab
Space
public string GetSomething()
{
return something;
}
Tab
public string GetSomething()
{
return something;
}
Block Statements
Curlybrace with one space
if (height < MinHeight) {
//...
}
while (isTrue) {
//...
}
switch (foo) {
//...
}
Curlybrace withat new line
if (height < MinHeight)
{
//...
}
while (isTrue)
{
//...
}
switch (foo)
{
//...
}
Curlybrace with no space
if (height < MinHeight){
//...
}
while (isTrue){
//...
}
switch (foo){
//...
}
Constant name
Constant is Pascal cased
const string FooBar = "baz";
Constant is all caps with underscore
const string FOO_BAR = "baz";
Conditionals
Condition with space
if (true) {
//...
}
while (true) {
//...
}
switch (v) {
//...
}
Condition with no space
if(true) {
//...
}
while(true) {
//...
}
switch(v) {
//...
}
Method arguments with one space vs no space
No space
public void SetName(string name) {
// ...
}
if(isTrue) {}
while(isTrue) {}
One space
public void SetName( string name ) {
// ...
}
if( isTrue ) {}
while( isTrue ) {}
Line Length over 80 characters
Line length is within 80 characters.
/* width is within 80 characters */
Line length is within 120 characters.
/* width is within 120 characters */
Line length is within 150 characters.
/* width is within 150 characters */
Special prefix for static var
No special prefix
static string name;
Special prefix
static string s_name;
Double underscore prefix
static string __name;
Private member naming
no underscore
string property;
public string Property { get { return property; } }
underscore
string _property;
public string Property { get { return _property; } }
m prefix
string m_property;
public string Property { get { return m_property; } }
Private method casing
Pascal casing as God intended
private void DoSomething()
{}
camel casing for people who hate the world
private void doSomething()
{}
What about elses?
These are the 3 main styles I think