Debugging with confidence
Most recently I was learning redux and really struggled with understanding the errors I was getting and how it all worked. I came to the realization, when it comes to programming 70% of your time is spent debugging and the remaining 30% is actually coding.
So why do we get bugs in the first place? If you google “debugging” this is how the term is defined:
noun
the process of identifying and removing errors from computer hardware or software.
This definition assumes the issue is with the logic but I would like to believe the issue stems from your mental model. Computers will perform whatever task we program it do but the reason the code gives errors is due the disconnect from our understanding and the expectation. With that being said, I think its worth confirming your understanding of how data is flowing throughout your application.
In my case, the types of redux errors I was getting were things like “route error” or “this.props.getStudents() is not a function” so this meant I had to retrace my steps from top to bottom. For instance, if I was attempting to submit a form and add the form data to the database through the dispatch function my steps would look like this:
- START: fire handleSubmit() in form component
- invoke thunk creator from props
- API request inside thunk creator
- middleware directs data to approriate place
- Database request
- Add instance/ row to DB
- Promise returned in variable “response”
- Res.send(response.data)
- Received by thunk creator / resolved promise
- dispatch action creator with response data
- reducer parses info and rewrites state
- state updated
- back in the form component
- END: prop should render updated state
As you can see there are alot of steps involved and errors can happen anywhere in that process. The key is having the clear understanding which will allow you to create a roadmap.
Get gURLmeetsCode’s stories in your inbox
Join Medium for free to get updates from this writer.
In summary, when you come across some errors and want to throw your computer in the river, try these tips:
- Retrace your steps. Try understanding how data is flowing throughout your application.
- Consider using the scientific method. Check out this blog post to learn more!
Happy Debugging!!










