Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
I ment that translate-name to be a function, as it has a verb and should do something, rather than be something.

About the length of the names and code-lines. How understandible a block of code is does not really relate to the length of expressions, but also to the formatting and the names. If the names are well-chosen but long, the formatting should be clear. Together with the way the program is broken up in functions, that determines the accesibility of some code, not whether expressions fit in one line or not.

For example, nested or sequential maps are a pain to read when put on a single line. Spread out over several lines the code often becomes clear. And we are talking about expressions with very short names. In this example it doesn't really matter whether your names are 10 or 30 characters, the code still gobbles up the same number of lines.

From another point of view, lines with more than say three or four variable names are probably hard to read anyway. Spreading it out over multiple lines can help than.

When browsing code like some linux kernel or whatever GPL program I need to tweak a bit to compile, I encounter C consisting of lots of comments intertwingled with short code. (And I wouldn't dare to claim that those are really well written examples) I find these things hard to read as well. The flow of logic in the comments is done by the authors, and is not the programming logic. There already is enough freedom in how to write code, the different ways to comment make code in general harder to read. I'd rather have to code spanning somewhat more lines than having those flexible comments in the way.....

About pre/post conditions. Tough topic, when I think of it. A condition is a circumstance before/during/after a function. I would say that such beasts belong to the interface anyway. They can or should be named in the function-name, or be explicitly mentioned in the parameter lists. Let us for example consider code that retrieves some user-information, and count the ocurrence of a 'p'. Pretty useless of course. Depending on a condition (eg are we running under windowz?) the list has to be pulled from the builtin functions or from an user file:

if ( $^O =~ /win32/) { get_userinfo_by_id_from_txtfile( $userid ); } else { get_userinfo_by_id_from_perlfunction( $userid ); } my $p_count_in_userinfo = count_p_in_array; report_p_count_at_interface( $p_count_in_userinfo, $reporting_interfac +e);
Depending on the remainder of the program, these interface choices may be a Good or a Bad idea. If we bury the win32 condition a bit further in the interface, which may well be a Good Thing for programs in general:
get_userinfo( $userid ); my $p_count_in_userinfo = count_p_in_array; report_p_count_at_interface( $p_count_in_userinfo, $reporting_interfac +e); sub get_userinfo{ my $userid = shift; my $is_this_gnix = get_gnixiness_system; get_userinfo_on_system( $userid, $is_this_gnix ); }
This can be extended forever, I think the idea is clear by now. With this naming convention, the conditions automatically get into the naming of functions and variables.

In reply to Re:{4} Commenting, was: Inline POD vs. EOF POD by jeroenes
in thread Inline POD vs. EOF POD by lachoy

Title:
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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (3)
    As of 2014-10-25 03:54 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (141 votes), past polls