How To Overcome Frustration When Programming
You inevitably hit a wall when programming from time-to-time.
The wall is unforgiving. The problem seems too difficult to solve. Or maybe you've invested too much time and effort into your solution and admitting it is embarrassing.
The feeling of frustration sets in.
What do you do?
Take one step. Frustration sets in when you aren't making progress and are in a reflective state of mind. Stop the reflection and begin by taking action on the problem.
Once you start to make progress, you'll stop focusing on your own frustration. Here's how:
Define the class of problem you are dealing with.
- Design: code is too complicated and overwhelming.
- Algorithm: not working as intended.
- Error message: an undecipherable error occurred.
Recall a time when you solved the same class of problem before.
- Replicate the same steps you previously took. The way you solve a class of problem doesn't change, despite the problem being different.
- For design, use paper and pencil. Draw out entities. Figure out what depends on what and how it could be structured better. Then get feedback and iterate.
For error messages, start by googling and then apply the same algorithmic process below:
For algorithm issues, identify the problematic line of code using logs or commenting out blocks.
- Use the debugger's question recursively: "What assumptions am I making that justify my expectation that my program will do X". Test assumption and ask again.
- Ask your closest team members.
- Ask on the relevant question/answer platform (StackOverflow) and come back to it later.
Your job is to keep chipping away at the problem in small increments, not be swimming in your own frustrations.