How to solve programming problems - a podcast by Kent C. Dodds

from 2021-03-06T18:28:44

:: ::

Hey friends so today is office hour stay and I am answered a question on
office hours that I thought I'd share with you and it's from Salem and the
question was hey can't can you walk us through the process for when you get
stuck on a problem and what I do is I try to find where the problem is.I don't try to just do a bunch of random things and hope that one of them
works or the solves a bug or whatever because what can happen is, you canimplement the wrong solution in the right place and and move the problem
andSo that you like you haven't actually saw the problem you just moved it
somewhere else and now you think that you've solved the problem but you're
gonna hear about this in the future and or like you might implementsomething wrong and and somebody else can create this problem all over
again, so you need to understand why the problem exists as well as how youcan avoid it in the future and then it can actually help to have a test in
place to make sure that the problem doesn't show up again, so one thing
that can be helpful is to write a test that that reproduces the problemfirst because that way like,You just have a much better iteration cycle on
did I fix it no or yes or whatever but another really critical piece ofthis is to isolate that problem so remove as much as you can and the best
way to do this is to reproduce it in a small isolated example, so try totake it outside of your app just install the dependencies that you know,
you need or whatever bring in the code that you know, you need andreproduce it in that small example sometimes that's possible sometimes it's
not but that's the best possible thing.
That you can do is to just remove as much as you can in a completelyisolated example sometimes it's a very difficult so if you can't then the
next best thing is to take your existing app where you're experiencing the
problem and remove pieces of code until ultimately eventually you'll wind
up with nothing on the page except the component that's giving you the
headache or whatever the case may be or you're running only a single file
on node that is causing the problem and and that can help you isolate theproblem sometimes that's difficult and so especially when you're talking
about like async stuff rate.Conditions or whatever console logs can be really helpful in in those
situations but yeah really finding where the problem is and if it's a
regression then finding which commit caused the regression can also bequite helpful so doing a get bisect whether using the command or just doing
it kind of by hand can also be really helpful in isolating the problem, sohopefully all that is helpful good luck to you in dealing with these types
of problems, it's no fun, but I know you can do it have a great day.

Further episodes of 3 Minutes with Kent

Further podcasts by Kent C. Dodds

Website of Kent C. Dodds