• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Java/C#/C++/[insert language here] brackets

Page 3 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.
Originally posted by: Jumpem
Originally posted by: Kilrsat
1

2 is just annoying and 1 also happens to be the standard we use at work.


You have those backwards.

The indenting will show you what all belongs to the same block. Wasting a line on a { just means you see less useful code on the screen at any point in time.
 
I used to exclusively use #2 but now since I've started to learn Java I've picked up #1. This is mainly because most of the coding examples in Java programming books use the #1 style of backets.

I tried switching years ago and failed miserably. The reason I've been successful now is that I took a hiatus from backeting all together since my programming has been in VB 🙂

#2 is easier to read, but someone who uses #2 exclusively will have trouble reading code that is written in #1.

Better to know #1 and still be able to read #2 than only know #2 and have a tough time reading #1.
 
i usually use method 1 but am gradually switching to 2. the architect of the project I am working on at IBM makes it a coding standard to use 2, since its easier to match up braces since they always line up.
 
#2 - it's so much easier to read.

Although for mundane stuff I'll often do things like this:
finally { myStream.Close(); }
 
Originally posted by: Mark R
#2 - it's so much easier to read.

Although for mundane stuff I'll often do things like this:
finally { myStream.Close(); }

it's easier for YOU to read perhaps, but not for the second half.
i used to do #2 and switched over, can't remember why, but ever since i switched over, it's been much easier for me to read. and i think

{

}

doesn't make it easier to debug, because your line of codes aren't going to be just 1 or 2, so you won't be able to sit there and match which bracket goes with which by eyeballing it.

it all comes down to the programmer's preference of which looks nicer, because they're both clean.

on the other hand this wouldn't ble clean

if (clean) { blah(); blah2(); ............................................ blah3(); blahend(); }

i do however do those if i only have 2 or 3 statements, i just rather not waste lines, and it shouldnt be hard to read
 
Back
Top