Mail Archives: djgpp/1995/06/15/21:07:41
> 2. Conditionals
>
> if (condition) {
> ...
> }
>
> if (condition1 || condition2) {
> } else {
> }
>
> if (foo && !bar) {
> } else if (bletch) {
> }
This syntax really bugs me and makes it harder for me to read the
code. I prefer this way:
if (condition)
{
...
}
if (condition1 || condition2)
{
...
}
else
{
...
}
if (foo && !bar)
{
...
}
else if (bletch)
{
...
}
The rule being that matching braces are always in the same column, and
nothing else is ever on the line with them. This makes it easier to
find matching braces visually and adds whitespace that makes the code
easier to deal with.
Note that I prefer two-space indents rather than tabs, as code tends
to wander off the right side of the screen too fast with tabs.
DJ
- Raw text -