Developer life can be tough; as devs, we constantly run into problems that we 1) don't expect 2) don't have the answers to (at least not right away) and 3) cause us distress and frustration. So how do we cope with the problems that give us so much trouble?
Just Walk Away
I know I know, it sounds like I'm giving you advice on how to handle a toxic argument with someone that you're really not liking at the moment. But when you think about it, the problems you face in development are just that: they're a dispute. You have a disagreement with the code, and at the same time the code disagrees with you. And when you're caught up in the heat of trying to prove your point (fix your code), your actions often stem from a place of impulsivity and short-sightedness. Similar to a nasty argument where you say things you don't mean, you tend to throw baseless solutions at the screen hoping for a breakthrough, and when they don't work, you become more frustrated. So instead of shouting at a brick wall, walk away for a bit and come back when you're ready to tackle the problem as the pragmatic developer you know you are.
Take One Day Off A Week
Let's face it: you can't program every single day without burning out before too long. Our job is difficult, and enduring its struggles every single day isn't only exhausting, but often counter-productive to our efforts. There are times when I feel as though I'm stuck in a coding tunnel vision and have lost sight of the bigger picture; for example, I recently encountered a very frustrating bug in my code. I tirelessly tried to fix it inside one single file where I thought the problem had originated. Turns out the problem bled a lot deeper and actually had nothing to do with the code I was working with, but I just couldn't see that because I was so burnt out from working in the same file for so long without taking a breather. I took the next day off and came back with some clarity and was able to pose some possible solutions outside of the tunnel I had been stuck in, one of which worked. So please, take a considerable amount of time away from your code every now and then - you will thank yourself later.
Your Code WILL Work Eventually, I Promise You
Lately, when something goes wrong in my development, I've been taking it a lot better. Rather than assuming the "whyyyyy isn't this working?!" attitude, it's so much more freeing to assume "this isn't working right now, but it will 100% work soon enough." It frees your mind. But it wasn't always this way for me. When something went wrong, it felt like the world was ending, and I never thought I would get out of it. But as I became more and more experienced, I noticed that rarely did I ever face an issue that wasn't eventually either resolved completely or met with a respectable work-around. So please be aware that almost every problem you will face has a solution.
I hope these tips earn you some kind of peace of mind, and good luck to you in all your development endeavors.