Subj : Re: Syntax, style, the infinite monkey theorum and coding To : comp.programming From : Ed Prochak Date : Mon Aug 22 2005 12:59 pm Rob Thorpe wrote: > Gerry Quinn wrote: > > In article <1124699428.796351.185650@g14g2000cwa.googlegroups.com>, > > gswork@mailcity.com says... > > > Ed Prochak wrote: > > > > gsw...@mailcity.com wrote: > > > > > > how about a C program with a seven page while() loop where the > > > > condition on the while() loop was seven full lines long (where full > > > > means about 70characters per line, not counting whitespace)? Sorry I > > > > don't have the code available. That was at a job nearly twenty years > > > > ago. It was written by a contractor that the company respected and was > > > > considered a great programmer. Needless to say I did not share that > > > > opinion when I was assigned to maintain and debug this beast. > > > > > > I like the idea that a condition can be seven lines long! Now that's a > > > condition! > > > > I can imagine that being a viable style in some cases, i.e. where there > > are several independent conditions that break the loop and each needs a > > comment: > > > > while( condition1 // comment > > && condition2 // comment > > && condition3 // comment > > ) > > { > > // do stuff > > } > > Yeah, I've seen code like this that is perfectly understandable. The > conditions to break-out of doing something complex can be quite > complex. > > It can be done in a nicer way, but this way isn't properly nasty. There are complex problems that require complex solutions, but trust me this was a case of monkey code. It was nasty and brittle (fixing one bug introduced another seemingly unrelated one). > > > It's the multi-page block that seems more problematic. > > Absolutely. AMEN! The whole application was full of extremes. Beside the 7page loop were several single-line functions, in this style: int importantFunctionName(){ return(globalvar++); } in the context of this thread, I'm honestly not sure which part is more "monkey code" than the other. Ed .