Subj : Re: Is well written code a rare species ? To : comp.programming From : Phlip Date : Sun Aug 14 2005 10:00 pm akarl wrote: > Joe Butler wrote: >> Maybe so for an 80 column terminal. But we were equipped with some >> new-fangled graphical monitors. They comfortably display more than 80 >> characters per line. >> >> Your book example is a classic non-sequitur. > > Books are formatted to be read by humans and source code is too. I don't > see your point. Overly long lines are simply hard to read. Moreover, > there's no cost to wrapping text at 80 characters, and there is certainly > potential benefit. Not that I have any (ahem) experience in the subject, but books use a fixed size type, so they must set the type big enough for most readers (including me). Then, books use portrait layout while monitors use landscape layout. So a formatting limit of 80 columns, in a book, corresponds to and does not contradict a formatting limit of, say, 130 characters in a source file. I am aware the effort of forcing 80 columns will lead to refactors that improve code style, like most cleanup efforts will. Most lines should "say one thing" in the least confusing way possible. Much code should use tables, such as C aggregate array initializers. These should be formatted into columns, making each column easy to scan. This breaks the "say one thing" rule, and such a table will push 80 columns if it contains anything useful. > y := stuff * distVal > + x > > Even if you use more than 80 columns you probably need to break lines > sometimes anyway. y = stuff * distVal y += x And don't get me started about :=. A math professor's self-righteous indignation that = some how does not mean "assignment", when CPUs cannot enforce an equality operation as rigorous as a math proof anyway, is completely specious and is not an excuse for us to type an extra : character in every single one of the most common kind of statement in all of programming. >> format might have been a better printing option. So, you see, it didn't >> make any sense - but what added insult to injury was the team went >> apoplectic when I started to format my functions thus: >> >> type >> function name( >> type parameter1, // comment >> type parameter2, // comment >> type parameter3 // comment >> type parameter4 // comment >> ){ >> blah blah >> } Uh, in theory so many parameters indicate a latent object, with its own commentaries. I will crack down on you regarding that rule shortly after I start following it myself... -- Phlip http://www.greencheese.org/ZeekLand <-- NOT a blog!!! .