Many of us have blind spots when it comes to reviewing or debugging our own code. We readily see problems in others' code that we're blind to in our own. We know what we just wrote, but our brains can't let go of our intent long enough for our eyes to really see what our fingers just typed. Peer review is the standard way around this, but often we're working alone, without ready access to qualified reviewers, and need to go it alone. Somehow, we need get our minds into a place where we can get past our blind spots.

Several years ago I picked up a way to trick my ego into getting out of the way. I offer it here in the hope that it'll resonate, or at least get others thinking.

My trick is to imagine that I had a fever when I wrote the code I'm now looking at, and that someone else had looked at it and pointed out that there were problems, but hadn't explain what they were.
This has a couple of effects. First, it gets my brain out of "there's no problem here" mode and into search-and-destroy mode. I really, really don't like having others find bugs in my code. (It's that damn perfectionist upbringing.) And to have somebody spot a bug and then not tell me... that gets me fired up even more.

By imagining that I'd had a fever, I sidestep overconfidence, and open my mind to the possibility that I was actually fallible at the time my hands were busily typing. I also pre-excuse myself for any problems that I find. (When I run a fever, my mind can play some mean tricks. I've learned to triple-check anything I try to do while sick.)

Thus tricked, my ego stays out of the way long enough for me to find lurking problems. When I remember to use this technique, my code comes out a lot cleaner.

That's what works for me. What works for you? How do you get your ego our your way?

In reply to Tricking Our Egos by dws

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.