• Create Account

### #ActualEddieV223

Posted 15 April 2013 - 02:46 PM

I used to code like this

void MyFunc()

{

int x = 2;

}

But then I read a book called Code Complete 2nd ed.  And it gave a great explaination why that style is bad and the other 2 styles that are good.  So now I code like this

void MyFunc()

{

int x = 2;

}

This style really pays off in complex nested loops and if statements, because you look straight down the braces and everything at that tab depth belongs to the line above, no question about it.  The first style breaks down and gets very confusing within complex code.

The other style the book said was good was

void MyFunc() {

int myInt = 2;

}

After comparing the 2 the straight line block of the 1st suggested method is much easier to read.  And thats what it is really about, making sure that your blocks are clearly defined so your brain can easily figure out the scopes and owner of blocks.

### #2EddieV223

Posted 15 April 2013 - 02:46 PM

I used to code like this

void MyFunc()

{

int x = 2;

}

But then I read a book called Code Complete 2nd ed.  And it gave a great explaination why that style is bad and the other 2 styles that are good.  So I now I code like this

void MyFunc()

{

int x = 2;

}

This style really pays off in complex nested loops and if statements, because you look straight down the braces and everything at that tab depth belongs to the line above, no question about it.  The first style breaks down and gets very confusing within complex code.

The other style the book said was good was

void MyFunc() {

int myInt = 2;

}

After comparing the 2 the straight line block of the 1st suggested method is much easier to read.  And thats what it is really about, making sure that your blocks are clearly defined so your brain can easily figure out the scopes and owner of blocks.

### #1EddieV223

Posted 15 April 2013 - 02:44 PM

I used to code like this

void myFunc()

{

int x = 2;

}

But then I read a book called Code Complete 2nd ed.  And it gave a great explaination why that style is bad and the other 2 styles that are good.  So I now I code like this

void MyFunc()

{

int x = 2;

}

This style really pays off in complex nested loops and if statements, because you look straight down the braces and everything at that tab depth belongs to the line above, no question about it.  The first style breaks down and gets very confusing within complex code.

The other style the book said was good was

void MyFunc() {

int myInt = 2;

}

After comparing the 2 the straight line block of the 1st suggested method is much easier to read.  And thats what it is really about, making sure that your blocks are clearly defined so you brain can easily figure out the scopes and owner of blocks.

PARTNERS