samperi@marob.MASA.COM (Dominick Samperi) (12/24/88)
From article <eWLGd#1tHJD6=eric@snark.UUCP>, by (Eric S. Raymond): |> I am genuinely |> interested in what y'all think of my aesthetic arguments. |Looks okay with me. I would have no problem maintaining code |that's formatted that way. I think your style is good. I posted similar comments recently, but suspect that my posting never left this site, so here it is again: In article <3261@ingr.com.> crossgl@ingr.com. (Gordon Cross) writes: |>The "throughout eternity" comment was my reaction to the thought of someone |>legislating my code simply because it does not conform to that someone's |>idea of "pretty"... Pretty? I think less subjective criteria should be used in cloosing a style... The style should facilitate the location of logical blocks of code, and should not require the programmer to think about details that have nothing to do with the program's logical structure. The purpose of using an indentation convention is to eliminate the need to think about these trivial matters when there is more important work to be done, and to permit other programmers who may have to work with your source code to more easily follow the program's logical structure. I advocate the following no-frills style: proc() { int x, y, z ; /* Easier to see ';' if it is preceded by a space. */ ... if(x > 0) { block1 } else { block2 } ... } This style does indeed facilitate the location of blocks of code, and it has another feature which is one of the major weapons that the programmer has to fight complexity: consistency (if-then blocks standout in exactly the same way that function body blocks do). I thought that very few people used this style, until I heard recently that in fact several large companies recommend it. Given the logical and natural way in which the C language was designed, I wonder if K&R might even have used this style if it weren't so wasteful of lines on a printed page. In large software development projects, wasting a few lines in source listings is certainly worth the human brain cycles that it may save. The style: if(whatever) { block1 } else { block2 } introduces an extra artificial level of complexity by requiring the double indentation for each block (and makes it more difficult to use the TAB key for statement indentation). The same arguments can be made for Pascal, suggesting a similar no-frills style, and avoiding those large '>'-shaped if statements, which tend to make it more difficult to find block boundaries, unless the indentation is done perfectly. -- Dominick Samperi, NYC samperi@acf8.NYU.EDU samperi@marob.MASA.COM cmcl2!phri!marob uunet!hombre!samperi (^ ell)