1. If you think you need to optimize, always profile your code first. Use Devel::Dprof for perl scripts, DBIx::Profile for DBI code, Apache::Dprof for mod_perl apps.
  2. Explore, Learn and Study CPAN. Look often at the recent uploads list. You never know when a module will come out that will allow you to re-factor out code from existing systems. Remember, even the most brilliant people understood the value of learning from those who came before:

    "If I have seen further it is by standing on ye shoulders of Giants." --Isaac Newton Feb 5, 1676

  3. Look at the source code of the CPAN modules you use. Worst case, you will learn some interesting uses for perl, best case you'll learn more efficient ways to use those common modules you thought you knew everything about.
  4. Format and comment your code as if you are going to return to it later for instruction. File the location of this code in your memory (or better yet docs), because if you need to do something similar you have a pre-existing code base. Learn to bootstrap your future development using custom made documentation and examples.
  5. Find a good text editor. Learn it well.
  6. Get involved in PerlMonks.
  7. The teacher will sometimes learn more than the student. By trying to explain a concept to another person, it's like you're learning it all over again.
  8. Keep everything as simple as possible. Write the least amount of code to get the job done. Just given the law of averages your likelyhood of making mistakes goes down. Besides that, the less you need to keep in your head at once, the more likely you are to understand the bigger picture.
  9. Understanding needs to come before automation, otherwise you will be doomed to solve your problem again, and duplicate the effort to re-automate it. I always solve the problem proceduraly before making objects, keep paper records before making a database, and design interfaces in HTML before making CGI's. Even though this doesn't always return perfect results, IMHO I believe the answer I come up with is usually closer to the ideal than without this methodolgy.

In reply to (dkubb) Re: (2) Random thoughts on programming by dkubb
in thread Random thoughts on programming by tilly

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.