Over the past few months, I've been using David Allen's Getting Things Done; in the process, I've started reading various sites that have to do with the "GTD" system and "lifehacks" in general. While catching up on LifeHack after a vacation, I stumbled on an article titled Organized People are Lazy!.

The Author of that article poses a few questions he asks himself when trying to be more efficient ("good lazy"). Since Laziness is one of the Three Noble Virtues, I immediately thought of how those questions might be answered for working with Perl. While I provide my answers below, I'm interested in what my fellow Monks have to say on the matter as well.

Question 1: How can I do this faster?

Focus on reusability. Even when you think you won't use your one-liner or snippet again, save a copy. Need to perform the same few steps over and over? Don't retype, don't cut-n-paste, factor out into a sub or a module.

Reduce debugging time. Using methodologies that keep bug counts low (like Test-Driven Development) let you get to release faster. Debugging without tests in place takes a lot longer (on average) than maintaining the test suite; you'll do less debugging, and what you have to do will go faster. Follow a "zero defects" approach (fix your open bugs before adding new features) -- fixing bugs in fresh code is a lot faster than fixing them in code you're no longer familiar with.

Question 2: How can I not do this at all?

Leverage existing work. Check CPAN first; chances are, a good chunk of your problem has already been well-solved. Use that work instead of rolling your own. Don't re-invent the wheel!

Redefine problems. Is there a way to think about your goals such that you can avoid work entirely? Are you optimizing prematurely? Do you really need all the features you're planning for this release?

Question 3: How will I remember this later?

Document and test! Use POD to document interfaces and user experience, use inline comments to document implementation decisions (even if you think they're easy to remember). Maintain a complete test suite (the laziest way to do that is to use Test-Driven Development); sometimes the best documentation is the tests themselves.

Question 4: How can I use my time better?

Get your priorities straight. Check CPAN for existing solutions; if none have all the features you need, pick one (or more) and add your features rather than starting from scratch. Avoid premature optimization: get a program that works correctly before you worry about how fast it is. Make sure you really need to save that 300ms of execution time before you spend hours optimizing. (In other words, make sure your optimization gains are worth the effort.)

<radiant.matrix>
Ramblings and references
The Code that can be seen is not the true Code
I haven't found a problem yet that can't be solved by a well-placed trebuchet

In reply to How to be lazier by radiantmatrix

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.