Hello monks.

I have not seen any discussion regarding this topic after a few searches, but it seem like a topic that must have been broached. Forgive me if my searches were not diligent enough.

One way that I try to maintain readability in my code (especially in projects involving multiple packages working together to perform associated tasks) is to give my subroutines readable, descriptive names. Given that any decent editor has some level of word completion these days, excessive keystrokes do not really pose an argument against this anymore.

A couple of examples of on of the funciton names that I'm using in a reporting package that I'm working on today are:
set_contact_source_type( $contact_id ); # where did the customer come + from? set_contact_pander_flags( $contact_id ); # how do they like to be cont +acted?

This style of naming subroutines becomes problematic when the subroutine is answering a yes or no question.
$answer = is_contact_male; # just doesn't look right. $answer = is_contact_female?; # Ahhh. Much better.

Is this something that other monks yearn for, or do you look at this code and say, "eek!"?


Thanks,
  Dug

In reply to Question Marks in Subroutine Names by dug

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!
  • 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, details, 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, summary, 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.