When you run into a code problem, bug or challenge - here are some steps to try get you out of your bind:
- Acknowledge that you will find a way to solve the problem. It might not be right now, today or even tomorrow, but at some point in the future you will solve it. As such, each attempt is an experiment. Succeed or fail, at each turn, reconsider what you think you know or what you think is happening.
- Clear some space in your day to think about what you need to do, write down the result you are looking for and how you might go about it. If you have a few options, great! Write them down too. Work backwards and forwards to try and break the problem down into smaller steps. Arrange them, re-arrange them. Basically, break the problem down into pieces and attack those one by one. Programming is far easier in incremental steps. Small results stacked on top of each other go a very long way.
- Consider that part or all of the reason you cannot solve this problem is because you are assuming something is happening that isn't. Maybe you aren't actually doing what you think you are doing. Or vice-versa, maybe you are doing the wrong thing. Re-trace your steps.
- Change is progress: If you are getting an error and then you get a different error this is good! Think about what you did, rewind the change and play it back. What is happening? Why did it happen? What does this tell you?
- Change is good in another way too: change of context. Take a break, get a cup of coffee, go for a walk, do something else for a while. It often helps to put the problem at the back of your mind for a little while. If you get to the end of the day with no success. Sleep on it.
- Google. Google is your fiend. Google your problem, see what you find. Read the source documentation. Try the example code. Look for similar examples. Read through Stack Overflow answers. Get ideas. Try different things. Most importantly, read the code. Maybe you are missing something? Chances are good someone has encountered the same or at least a similar problem to yours.
- If you are getting really stuck, try and separate the problem out into a simplified version of things. If you can get a basic example right, maybe you can build something up to contribute towards a more complex one.
- Rubber-duck debugging
- If you are still stuck, search for a video course that is similar or matching your problem. You will be amazed at the courses and content you can find online. Sometimes, spending a few hours and few rands/dollars/euros on solidifying your knowledge and skills can go a very long way.
- If you have tried all of the above, and I mean really tried, then enlist some help. Before you do though, take a break, retrace your steps one by one and repeat the Rubber Duck strategy before you do. It's always worth one more shot.
TILs of the week: