From: Malcolm N. <m.n...@wa...> - 2008-10-03 06:43:32
|
On 03/10/2008 07:15, Tony Reina wrote: > > > 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. What's wrong? Don't like Southern Comfort? :) > 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. What tool does it this way? I'd like to take a look. I understand what you're saying here, but if my style was enforced, (and this is purely personal opinion here) when viewing the source with several embedded if then stuff if (some condition) { if (some other condition) { if (yet another condition) { } } } and the reader only has to follow the brace up or down to find the associated brace and or condition. Unfortunately wxDev at the moment only highlights the brace itself, which is unfortunate, since I can see the advantage of highlighting the complete line including condition. By the way, have we changed the brace highlighting code anywhere? I can remember that the matching braces were highlighted in inverse video at some point, which made them easier to see, but currently the matching brace is simply bolded. Or is this something quircky on my end? Or am I getting confused with another ide? > 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)" I can go along with this, although I can see the code getting crowded, unless we enforce a wide space (say 3 tabs worth) between the brace and the comment. if (Something) // YES { // Begin "if (Something)" ... code ... } //End "if (Something)" I was once pointed to an "elastic tabs"idea once, the idea being that all tabs were lined up, and not just at the 4 char boundary. http://nickgravgaard.com/elastictabstops/ That looked interesting, I wouldn't mind seeing that in the ide. Best Mal |