Subj : Re: Is well written code a rare species ? To : comp.programming From : Chris Sonnack Date : Mon Aug 15 2005 07:03 pm Joe Butler writes: >> ....that overly long lines are harder on the eyes than short ones. >> Newspapers are printed in columns, in part, for that very reason. > > Yes, I agree. But I'm suggesting that an arbitarily-chosen cut-off is > counter productive. I don't think anyone is claiming that the normal > distribution for readability and other good metrics is centered at 80 > columns - which is why I find it so difficult to accept this rule. Agreed. It's a general guideline in my book. And, FWIW, I find I almost never print source anymore. It was just a waste of paper. I'd usually spot something I wanted to change while walking the printout back from the printer, so the printout became obsolete almost the instant it was printed. >> To make those easier to spot, I often do something like this: >> >> return_type >> function_name ( type parameter1 >> , type parameter2 >> , type parameter3 >> , type parameter4 >> ) >> { >> blah, blah, blah... >> } >> >> I've learned over the years that the more *visual* structure I >> can put in code, the easier it is to work with. > > I'd probably agree with the visual structure comment, but I find commas > floating out in space like that extremely jarring for some reason. It's a little odd. Like many things, that oddness goes away if you decide to go with it and get used to it. I've found it useful for reasons of visual structure. > The compiler will always catch these errors anyway. Certainly. > At the end of the day, the different styles add some variety - I > wouldn't constrain my programmers to such rigid rules. AGREED! Rigid rules just about anywhere are a recipe for disaster. > // compressed (no spaces) yet, inexplicably, the braces > // are each placed on a line of their own - totally weird to me. > for(x=0,y=0;x { > > } Given my choice between the above and the below, I'd take the below. > // exploded code > for ( x = 0 , y = 0 ; x < n ; ++ x , ++ y ) { > > } Assuming it's not something amUSENET added, I find the assignment style odd. Spaces or no spaces, make up your mind! :-) > // my own 'style' > for(x= 0, y= 0; x < n; x++, y++){ > > } I'm also increasing of the opinion that the opening brace should (in almost all cases) be on the same indent as the closing, but that's just *my* sense of style. > // not me cos of the pre-increment > // I know, it's more efficent (sometimes) > for (x= 0, y= 0; x < n; ++x, ++y) > { > > } Agreed on the pre-incr. I do use them when the statement is on its own line (in C-family languages), because I don't like the trailing semi-colon near the "++". ix++ ; // yuck ++ix; // preferred I'd write your example as: for (x=0, y=0; x < n; x++, y++) { } -- |_ CJSonnack _____________| How's my programming? | |_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL | |_____________________________________________|_______________________| .