Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
    I like it a lot (I know, I could even leave out the "return").

My background as a C programmer requires that I always include the 'return' at the end of a subroutine. It's a visual reminder that explicitly states that a value is going back to the caller.

    However, in a few months I'll be off to new challenges and I will have to leave this code to be maintained by somebody else.

Should your legacy be "Great code, but it took hours to figure out." or "Great code."? You may be working with these people or their bosses again -- you have no idea how small the world is until you've been working for a few years.

    Should I let my pride prevail and leave the code as it is, our should I be merciful to the maintainer and refactor it to something more readable to the non-initiated?

I've heard that "Pride goeth before a fall". :)

I highly recommend a) a comment explaining this cute piece of code, b) the addition of a few (unnecessary, I agree) braces to make the syntax more obvious, and c) leaving the 'return' in.

Other replies notwithstanding, it took me a little while to read through that and figure out what it did. If we assume that the person who is going to maintain this is not as skilled at Perl, they'll probably be stumped. And if they're stumped, you'll probably get the call to interpret the code. At least if you've left something that's understandable, the explanation will be brief. If it's halfway to an obfuscation, that's not going to help anyone.

The only reason I can think of for writing something clever, but difficult to read, is speed. Assembler hacks come to mind, an area of software development that is brutally honest. This isn't such a case. Swallow your pride and leave behind a readable, if somewhat less beautiful, piece of code.

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

In reply to Re: Should I leave behind beautiful code or readable code? by talexb
in thread Should I leave behind beautiful code or readable code? by MaxKlokan

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (4)
    As of 2018-05-22 22:32 GMT
    Find Nodes?
      Voting Booth?