"How can I re-use this?" is something that I'm trying to make a mantra, especially after reading through The Pragmatic Programmer a couple of times. Modular, orthogonal code is a Good Thing.

Not really a mantra, but one concept that's stuck with me pretty much forever is the idea of conservation of difficulty, which was introduced to me by one of my profs in an intro programming course. The idea is that every problem has a set difficulty, and making some part of the solution easy (writing hacked-up, off-the-cuff code, for instance) will make another part difficult (debugging). Sometimes, the tradeoffs between easy and difficult are political at best (doing the hard bit when nobody's looking, and saving the easy finishing touches for when your boss shows up), but (here's the tie-in with reusable, orthogonal code) often you can do the difficult bits of many problems once -- by writing a module to do something clever that relates to a bunch of your problems, or spending an hour or two putting together a really elegant interface to a function you'll call a lot, for instance.

"How am I going to debug this?", and it's friend "How am I going to test this?", are ones that I should keep in mind, though.

--
:wq

In reply to Re: Programming Mantras by FoxtrotUniform
in thread Programming Mantras by dws

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.