From: Tony R. <tb...@gm...> - 2008-10-03 05:15:25
|
> > For if, else, while and similar statements put the brackets on the > > same line as the statement (this makes it easier to see if the IDE has > > a matching braces tool) > > You want > > if ( /*Something*/ ) { //YES > i++; > j++; > } > > > I'm willing to concede the point to you. The reason I prefer it the former way is because on the trailing bracket, it is often hard to tell which starting bracket it goes with. For example, if (Something) { //YES if (SomethingElse) { if (SomethingOther) { ... lots of lines of code, many with other embedded brackets... } } } // END YES If there are, say, 3 or 4 embedded if-then brackets, it may be hard to tell what the //END YES bracket goes with. In many IDEs, however, there's a brace matching tool which shows the matching brace in the command line. In my case, it would show: if (Something) {YES in your case, it would show: { So I'm just pointing out that in my style you get more info on the matching brace. Perhaps a happy medium would be to use your method, but require developers to add comments to their braces (both beginning and end). e.g. if (Something) // YES { // Begin "if (Something)" ... code ... } //End "if (Something)" -Tony |