# Debugging & Troubleshooting
## [[Software Bug]]
## Be methodical
- Don't try too many changes at once since you won't know which change is causing the problem.
## Isolate the problem
- Comment out other things
- Even better, isolate what you are troubleshooting in a totally different program, codepen, etc.
## Useful debugging features in IDEs and editors
### Run to Cursor
### Step over, step in, step out
### Go backwards? Visual Studio can
### Watch Expressions
### Breakpoints
- where the program will stop and then display a bunch of data about the state of variables, etc.
### Conditional Breakpoints
- E.g. to stop at a certain loop iteration
## 3 Kinds of Errors
### Logic Error
- https://en.wikipedia.org/wiki/Logic_error
- aka Semantic error
### Syntax Error
- Occur during the parsing stage
- Syntax errors may occur somewhere different from where the interpreter reports it.
- https://en.wikipedia.org/wiki/Syntax_error
### Runtime Error
- Occur during the execution stage
- Exceptions
- https://en.wikipedia.org/wiki/Run_time_(program_lifecycle_phase)
## Use print()
### To show the value of variables as it executes
### To show when a program gets to a particular point
## Global and local variables
## Whitespace Errors
## Matching parentheses, brackets, etc.
## Order of operations
## Google
### Quoted error message
## Ask others
### r/learnprogramming
### Stack Overflow
### Code Newbie Slack
### Ask good questions
- List software versions you're using
- I think LaunchCode has a link about this
- I think ATBS has a section that's good
- Be nice, clear, concise
- Post complete error message and code and specify where/when the issue occurs
- Is it repeatable?
- gist.github
- After a change in code? What change?
- Does it occur after a certain action? What action(s)?
- Explain what you have already tried
- https://superuser.com/help/how-to-ask
- Explain ultimate goal
## Rubber Duck Debugging
### https://en.wikipedia.org/wiki/Rubber_duck_debugging
### https://rubberduckdebugging.com/
### [Just talk it out loud and there you go! : r/ProgrammerHumor](https://www.reddit.com/r/ProgrammerHumor/comments/jgib4q/just_talk_it_out_loud_and_there_you_go/)
## [[Root Cause Analysis]]