10 Programming tips and tricks to stay sane

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:

  1. 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”
  2. Print statements are the easiest form of debugging. Use them everywhere
  3. 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
  4. 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)
  5. 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!
  6. 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.
  7. 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
  8. 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
  9. 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
  10. 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!
  11. 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!