http://www.perlmonks.org?node_id=162746


in reply to What is clear code ?

Don't feel bad. Strictly on readability, I actually like yours better. Not necessarily because of the "number of concepts."

For me it's simply because it can be read top-down (instead of bottom-up). I despise having to visually scan down several lines for the semicolon, and scan back up to see what's being done. With all of the comments, yours is far more readable to me. Remove the comments, and his becomes much better. One grouping, one explanation.

Ovid's would be re-written as:

sub Readable_Ovid_Clear_MakePtag{ my $fixme = shift; # make newline-breaks into HTML paragraphs return join "\r\n", map { "<p>$_</p>" } grep { /\S/ } split "\r\n", $fixme; }

Replies are listed 'Best First'.
Re: Re: What is clear code ?
by Fletch (Bishop) on Apr 29, 2002 at 14:06 UTC

    If you've done any Lisp (or other functional style programming) you kinda get used to parsing things inside out. You almost could wrap parens around Ovid's version and . . . :)