Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: How to Teach Debugging?
3 points by fdeage 10 months ago | hide | past | favorite | 7 comments
I am teaching a data science class to people with little to no programming experience. The course uses Python and various ML libraries, and Docker.

I find very difficult to provide the students with a general method of debugging. I find Feynman's method ("think hard and solve it") discouraging.

Anything more step-by-step?

EDIT: typo




0. Define the intended behavior and the current behavior.

1. Come up with a hypothesis for why they don’t match

2. If you’re unable to come up with a hypothesis (“I’m sure it should work”), then that means you’re assuming something that isn’t true. Identify one of your assumptions and take it as your hypothesis.

3. Gather data until you’ve either proved or disproved your hypothesis. This can be done by designing an experiment, inspecting variable values using print statements, reading documentation, or etc.

4. With this new information, circle back to the problem. Either attempt a fix, or generate a new hypothesis and start at 1.

Students, and programmers of all skill levels, get stuck at every step. Some other tips:

* Ask for help only with the step that you’re stuck on. You can ask for help creating a hypothesis, but don’t ask for help gathering data at the same time. This keeps questions focused.

* Be mentally prepared to run through this loop many many times until the problem is fixed.


Thanks! It's like an extended Feynman. It also reminds me of this: https://jvns.ca/blog/2022/12/08/a-debugging-manifesto

You're right to emphasize the looping it takes to solve bugs. Many students are not prepared for this.


Yeah, I did a talk on "Debugging JavaScript" that really is mostly language-agnostic and focuses on the core scientific method approach:

- https://blog.isquaredsoftware.com/2023/06/presentations-debu...


Very interesting, thanks!




Liken it to working on a crossword puzzle




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: