Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: Should I leave behind beautiful code or readable code?

by BrowserUk (Pope)
on Mar 28, 2007 at 11:25 UTC ( #606982=note: print w/replies, xml ) Need Help??

in reply to Should I leave behind beautiful code or readable code?

For counterpoint. One wonders how many of those who are advocating dumbing down this simple code, actually had any trouble understanding it? There is a common theme here where people tend to say: I understand it now, but a maintenance programmer (or you) 6 months from now may not. Even though they have just encountered the code for the first time and so are in exactly the same position as the mythical maintenance programmer will be in 6 months from now.

With the exception of the possible abiguity of the use of / / as the parameter to split--which in the light of knowledge of the code, may not be ambiguous at all--anyone not immediately able to understand this code, should probably not be maintaining Perl code anyway.

What is the point of using a Very High Level Language (VHLL), if you mandate not using it's high level facilities? If these people ever opt to use Perl 6, they will only ever use 50% of it facilities, because they will reject the rest on the basis that it is too complex.

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Should I leave behind beautiful code or readable code?
by bart (Canon) on Mar 28, 2007 at 11:50 UTC
    You took the words right out of my mouth. Not that I'd have used the orignal snippet as an example of beautiful code...

    It's time we snap out of this. If a maintainer can't understand code as simple as this, it's time for him to get educated. People should stop wasting time writing verbose code, and learn more elegant ways to do the same things. It's time they start to learn to recognize the typical Perl idioms, and stop trying to write a shadow of C in Perl.

    Who in his right mind would dare to call lines like

    for($i = 0; $i<$max; $i++) { ... }
    "simple" and understandable? It's verbose, it's ugly, it's impossible to read, and the only reason why people think it's readable is because they have learned to read it. And to be honest, it probably took them a relative long of time to learn it.

    It's time to learn something else.

      Isn't this the point of comments? I mean, so you can write code, which ... well is almost by definition not natural language, to do something, and then put a comment by it to explain how and why it does it?

      I don't care what a line of code does. I do care, that someone's taken the time and effort to document or comment what that bit does, if there's _any question at all_ about whether it's easy to understand or not.

Re^2: Should I leave behind beautiful code or readable code?
by f00li5h (Chaplain) on Mar 28, 2007 at 12:00 UTC

    BrowserUk++ 'ere 'ere.

    I never really thought how patronizing my attitude towards my maintenance programmer is. I'm sure he's good at perl, otherwise he wouldn't have my job ;)

    @_=qw; ask f00li5h to appear and remain for a moment of pretend better than a lifetime;;s;;@_[map hex,split'',B204316D8C2A4516DE];;y/05/os/&print;

    Update Spelling does not work that way.

Re^2: Should I leave behind beautiful code or readable code?
by Cap'n Steve (Friar) on Apr 01, 2007 at 07:55 UTC

    Is cramming everything on one line really a "high level facility"?

    The OP asked this question because he thinks it could be easier to understand. True, it's not all that hard now, but why on Earth would you argue against possibly making your successors job easier?

    The positives of reformatting it: The next guy might be able to spend a few seconds less figuring out what it does.

    The negatives: Will you really cry yourself to sleep at night knowing someone is using some of your code that isn't "beautiful"?

        I think some of the replies already posted have been good suggestions. I don't know about you, but spreading that to 3-4 lines and adding the braces definitely makes it easier for me to read.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://606982]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2017-08-23 22:43 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (360 votes). Check out past polls.