Tuesday, 1 January 2013

Java: Handling Braces

It is good programming practice to maintain a format when coding. These formats can be anything from indentation, white spaces, line wrapping, separation of code and braces handling. Why is it important? - To make the code readable.

There are two distinct way of handling braces:

1. K&R style

while(a!=b){
     doMethod();
}

2. Allman Style

while(a!=b)
{
     doMethod();
}

Personally I prefer the K&R and I practice it on my code. Always remember, good coding practice makes a good programmer. :)

0 comments:

Post a Comment