When you realize how dumb a bug is...

Started by
150 comments, last by Juliean 7 years, 4 months ago

I wonder what an equivalent programmer trick might be?
Standard trick when writing scientific papers is to leave it alone for a few days, then read it asif it was made by someone else.

With code, I can usually do it quicker, around 12 hours does the trick for me.

I recently found out that waiting even longer has benefits too. I didn't touch a project for several months, and when I returned to it to decide next steps, I could see a much bigger picture of its state and the goals, and made a number of big decisions in the general direction of the project.

Advertisement

The problem in many cases is that you read what you think you wrote, not what you actually wrote.

Many times I talk to my friend about what I programmed and what it does (or doesn't because of a bug) just in the sake of telling someone what I did "today" even when my friend has no clue about any sort of programming.

Then afterwards I think what I said and sometimes I "accidentally" give a clue to myself what I did wrong when I think it from not-a-programmer's point of view non-code wise.

Also what Alberth said, keeping a break also helps with that, but for me helps even more if I talk to someone about the code. Usually I just talk to a specific friend of mine though. He knows that it might help me find a bug in the game so it's all good, my other friends would probably just go mad haha.

EDIT: When I sometimes make a piece of code and there's a bug somewhere which I don't find, I occasionally post it somewhere. After posting I read the post through for any typos and actually realise where the bug is.. then I feel a bit stupid

"Two plus two equals five ... for extremely large values of two."

Many times I talk to my friend about what I programmed and what it does (or doesn't because of a bug) just in the sake of telling someone what I did "today" even when my friend has no clue about any sort of programming.

That's sometimes called "rubber ducking", because some people use a rubber duck or a portrait of a famous computer scientist like Donald Knuth of John Carmack to "explain the problem to".

Today, Intellisense suddently stopped working (code completely black, no suggestions), after I left to get some food. I spent 2 hours trying to reset stuff, repull the repo, even installed f*cking Visual-Studio 2017 (already been negatively conditioned towards VS2015 being buggy for me...), but couldn't get it to run.

By accident, I landed on an older branch of the project, and now suddenly everything was working again. I realized that this bug would only affect certain files in the newest commit, but since changing include files only sometimes and inconsitently worked, I pretty much ended up undoing every single file until I finally got some highlighting in the affected files. I found the responsible file, which had numerous changes, so I undid every single unit of change until I found whats responsible:


template<typename AttributeEntry>
struct BaseDeclaration
{
    using EntryVector = std::vector<AttributeEntry>;

    BaseDeclaration(std::wstring strName, EntryVector vEntries) :
        m_strName(std::move(strName)), m_vEntries(std::move(vEntries))
    {
    }

    template<typename OtherEntry>
    BaseDeclaration(std::wstring strName, std::vector<OtherEntry> vOtherEntries) :
        m_strName(std::move(strName))
    {
        // ... doesn't matter
    }

    // ...
};

The addition of the second constructor fucked up intellisense, but only outside of this file (inside the file, everything worked fine) and without any kind of warning/error. Removing it fixed everything. Sigh. I'm still trying to figure out whats the exact problem (probably ambiguity?) and how to circumvent it, but I just needed to let out some fruststration about a totally wasted evening...

This topic is closed to new replies.

Advertisement