Sometimes, when I try to code something, pouring extra hours of effort into it, I can just feel how close all the pieces are to falling into place. Then I realize I'm going in circles, spending more time than I meant to, and a solution, whatever it might be, has escaped me at the moment. Git checkout, try again later.
Other times, like this last weekend, the extra hours pay off. I needed to make some adjustments to our test environment to support QA efforts, but it included some significant refactoring of one of our solutions. A couple times I hit a wall and had my trigger finger hovering over the "git checkout" command.
Then I had a conversation with a coworker, who helped me realize that I had already solved the problem and something else was preventing it from working. Voila, problem solved! What a great feeling, knowing the gamble paid off, and I reworked something in a way that'll benefit the entire team moving forward.
The trick now is to hang on to that memory, to get me through the next thing that doesn't work out so well. I used to think there were things that were beyond my ability to understand, things that I just couldn't figure out. Now I realize there are things that take me a short time to understand, and things that take a long time. Maybe more time than I have right now.
Even when I do call it quits and abandon the attempt, it's seldom a waste. It casts light on things that were dark and brings with it a certain understanding that'll apply to other types of problems too. And to paraphrase Thomas Edison, I've learned one way not to fix it. Life goes on; next time will be better.