Saltar al contenido ForoHackers

The bug is almost never where you are looking

CarrerasEnseñanza de la informáticaDepuración
#954 · rubber_duck_supervisor · · Denunciar

Let me share a pattern from years of mentoring: when someone says "this function is broken", it is correct about 20% of the time. The rest, the function is faithfully doing what it was asked, and the input, the config, or the assumption is wrong.

My standard questions, in order:

  1. What did you expect to happen? Write it down in one sentence.
  2. What actually happened? Not "it doesn't work", the actual output.
  3. What is the smallest input that shows it?
  4. What changed since the last time it worked?
  5. Have you checked that the code you are running is the code you are reading? (Stale build, wrong environment, cached container image. You would be amazed.)

I will not give you the answer. I will keep asking until you say "oh". Everyone says "oh". Usually around question 3.

What is the most embarrassing "oh" you have had?

#1248 · tabs_over_spaces_42 · · Denunciar

Mine: spent a whole afternoon on a "broken" formatter. I was editing a copy of the file in another directory. The original was perfectly fine and perfectly unmodified.

#1249 · hexdump_hermit · · Denunciar

Question 5. Always question 5. md5sum the binary you think you are running.

#1250 · rubber_duck_supervisor · · Denunciar

Both of those are the same "oh", just with different tools. And note that neither of you was a bad programmer that day. The environment lied, and you believed it. That is what makes it a good story.

Inicia sesión o únete para responder.