And remember, what is beautiful today, may be considered ugly tomorrow. (can anyone remember the fashion styles of the 1970's?) There has recently been the thread started by Tilly on Random thoughts on programming, where a number of monks shared their wisdom on good program design.

If I were implementing such a "have I got that item in my list?" function, I would also include in the code the "key" to where in the list that item is, just in case I will want to do something to that item. Now, if we use a hash, then we get that:

$my_hash{$key_value} = 'Stuff up the value real good';
Otherwise, if I have a function that tells me whether the item is in the list, I would have the return value being a logical false if the item was not found, or the direct key to it if it was found. If you are doing a simple logical test, then returning a defined value is (should be) accepted as "true" (see page 20 - 21 "What is Truth" of the Camel book).

If it wasn't first thing in the morning, I would attempt to hack a bit of code demonstrating this, but I am sure you all know what I mean here. The essence of what I am saying is that a good programmer looks ahead, and allows for the foreseeable future requirements.

Updated: Stupid typo in code fragment fixed. I should finish my coffee before coding.


In reply to Re: Beauty is in the eye of the beholder by Maclir
in thread Beauty is in the eye of the beholder by ChOas

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.