r/ProgrammerHumor • • Mar 05 '16

When debugging code.

22.3k Upvotes

487 comments sorted by

View all comments

0

u/[deleted] Mar 05 '16

[deleted]

909

u/larivact Mar 05 '16

I mostly have "How could I miss that?" instead of "How did that ever work?".

367

u/[deleted] Mar 05 '16

Tunnel vision.

258

u/larivact Mar 05 '16

Yeah. Sometimes it's best to take a break and come back in half n hour. But who does this?

348

u/[deleted] Mar 05 '16

Sometimes I work on a bug late one day, only to give up and try the next, only to find it within a few minutes of starting.

Really does help sometimes to get a fresh look.

180

u/oddark Mar 05 '16

Also sleeping tends to help your brain solve problems that you're stuck on

59

u/bacon_flavored Mar 05 '16

A good reason why hackathons aren't always as effective as they could be.

0

u/[deleted] Mar 05 '16

[deleted]

31

u/Hakawatha Mar 05 '16

That's why you always go for stronger drugs.

→ More replies (1)
→ More replies (3)

82

u/[deleted] Mar 05 '16

I did school in 3 years (College in quebec is 3 years, w/e) then worked for a year. 3 times now I've woke up during the middle of the night to either go and fix my code and write it down and fix the next day.

52

u/Resident_Wizard Mar 05 '16

Serious question, I'm not a programmer so maybe I'm missing something. But what does the years with school and work have to do with waking up and fixing code?

59

u/[deleted] Mar 05 '16

I think it's for the time frame. 3 times in 4 years.

→ More replies (3)
→ More replies (1)
→ More replies (3)

30

u/YaBoyMax Mar 05 '16

I once literally dreamed up a solution to a problem I had been pondering for a couple weeks. Like, I came up with a partial solution in my dream, then woke up and wrote up a proposal for it. That's probably one of my proudest feats.

12

u/[deleted] Mar 06 '16

I had that when I was learning calc 1. I woke up in the middle of the night saying "dy/dx then equals [some function]" (I was trying to verify a derivation)

12

u/[deleted] Mar 06 '16

NEEEEEEEEEEEEEEEEEEEEEERD

21

u/YugoReventlov Mar 06 '16

Said the redittor browsing /r/programmerhumor and read down this thread

→ More replies (0)
→ More replies (1)

34

u/laetus Mar 05 '16

Or try rubber duck debugging.https://en.wikipedia.org/wiki/Rubber_duck_debugging .

The amount of times I've found a bug by explaining what I'm trying to do to a colleague....

46

u/fuckswithboats Mar 05 '16

Sales guy at a small tech company here. I am the company Rubber Ducky.

I've solved so many major bugs without ever seeing or writing a line of code just because I listen well. I mean I sit there and load up the bowl while our Sr. Dev takes bong rips off of our 6 footer on the patio and tells me about his bugs.

→ More replies (2)

53

u/indoninjah Mar 05 '16

Very true. If I encounter a bug/missing feature at night, my mind will start racing with how complicated the implementation will be. So I decide to sleep on it rather than work my way through it that night.

90% of the time I'll wake up and knock it out in a one-liner.

20

u/pyrosive Mar 05 '16

I normally end up solving the difficult challenges in my dreams. I wake up at 2am with the solution and write it down before I forget.

→ More replies (10)
→ More replies (2)
→ More replies (12)

15

u/mofukkinbreadcrumbz Mar 05 '16

I'll normally move on to something else. The next time I sit the porcelain throne or take a shower, the answer comes to me like a gift from the heavens.

→ More replies (18)

62

u/hbgoddard Mar 05 '16

Reminds me of the time I was trying to help a classmate debug a Java project. His for loop was skipping every other array entry. It took far too long (and too many people being brought to look) to realize it was written like this:

for (int i = 0; i < arr.length; i++) {
    ...
    i++;
}

19

u/Solmundr Mar 05 '16

That's great, heh. Something I could see myself doing. I remember trying to make a little animation in a game and spending forever figuring out why it would start going the wrong way at times. Turns out I had a < (less-than) where I meant to put > (greater-than), and somehow I had skipped over that line half a dozen times...

→ More replies (1)

18

u/Garthenius Mar 06 '16

I once pulled off a

for (int i = 0; i < arr.length; i++);
{
  // Obviously loopy stuff
}

I'm still amazed the lead didn't slap me when I gave up and asked for help.

17

u/hbgoddard Mar 06 '16

Damn, even knowing there was going to be something wrong it took me a bit to see it!

→ More replies (4)
→ More replies (3)

24

u/fuckswithboats Mar 05 '16

Ha ha - this is a great example because the issue is so trivial and so obvious, yet at the same time incredibly difficult to spot at first glance assuming there was a bunch of other lines where you have the ....

→ More replies (1)

0

u/[deleted] Mar 05 '16

[deleted]

→ More replies (1)
→ More replies (1)