Below are some mental and practical tips and tricks which have helped me so far from microwaving my laptop and running away to live in a forest. In no particular order:
- Develop incrementally. Run your code often – unless your doing time intensive work like training a neural network, this will keep you from those moments of “oh no I’ve spent 2 hours writing nonsense”
- Print statements are the easiest form of debugging. Use them everywhere
- But use a debugger when really stuck. Also – learn how to use a debugger properly and how to actually debug something! Stepping through stack frames then sticking a break point back in your code is a good way of seeing how your code interacts with whatever API’s you’re working with
- Google well i.e. :
- phrase the problem well – this reduces searching and guesswork
- rephrase the problem in terms of what you are actually trying to do
- Sometimes phrasing the question well will answer it for you (I especially like just typing my question into StackOverflow’s search-box as a quick way to see similar problems)
- Get you head in gear…don’t overthink things. I like to listen to some sort of EDM when I code because that help my fingers move faster. Also it helps me think. Find what works for you!
- Learn how to use your IDE of choice. If you are going to use a good IDE instead of torturing yourself with Vim then take the time to learn it. Look up the shortcuts and maybe a quick intro youtube video. It’s 10 minutes that will save you a lot of time in the future.
- Understand the problem. Sometimes problems are specific and easy to deal with, other times they are nebulous and hard to get your head around:
- Do you understand the problem? Say it aloud, explain it to someone else and if all else fails talk to your goldfish (they’re smarter than rubber ducks)
- Break it down into concrete steps
- Don’t get stuck in a loop. If you get really stuck on one bit, then do another bit – you won’t waste your time and you will come back to the error fresh
- Be prepared to start again from scratch. Sometimes your whole approach is wrong and this is why you are having such problems – try and list all the different approaches and pick the one you think is best
- Look after yourself. Eat well, sleep well and exercise often. See your friends, get outside (especially when it’s sunny) and have some downtime in the evening to play games or read or whatever you’re into. There’s more to life than coding!
- Bonus 11th (and maybe the most important): Never be afraid to ask people for help. Whether that’s online or if you are lucky enough to be employed then your colleagues. We’re all developers, we all need help sometimes. No developer is an island to themselves!