I get hung up in a number of ways, but the most severe is when I'm trying to learn how the existing system works. I'll be listlessly paging back and forth between spaghetti code classes, and things get all fuzzy, and then it feels like I've spent enough time on this, and some sort of strategy to do my project occurs to me.
And then I try it, but it doesn't work because I still didn't understand the existing code. Rinse, repeat.
However, just the other week I decided somehow to FIGURE OUT HOW IT ALL WORKS, DAMMIT. I actually kept a glass of ice cubes next to my desk and pressed one to my head if I felt I was drifting, which worked surprisingly well. I realized that this codebase always had a lot of the functionality I had always wanted, hidden away in a particular method. I'd been staring right at it for months and it didn't click in my head.
> Luckily I still have a reputation earned from some years ago.
You've been capable of doing good work in the past, but you're deeply critical of your current work:
> I felt ashamed. ... and my code is ugly.
When you try to work, do you start on an approach but then doubt it and lose momentum?
It could be anxiety. Here are some thoughts:
1. Remember that programming is difficult and takes time. Adjust your expectations to accept slow progress.
2. Refuse to churn, even if it means writing crap code. Consider everything you write at the outset of the project/day/feature to be a rough draft. You will return to revise it, so the rough draft can be utter crap.
3. Keep your focus on a small corner of the project. Seeing the big picture can help you design a higher quality system, but considering the big picture for too long or too often allows your mind to despair. Todo lists help, but the attitude of ignoring everything but the current task helps more.
Pay attention to what you're thinking about when your mind fuzzes out. Are you worrying about something? Learn to recognize the beginning of your focus dropping away.
You said this:
> it's more about what I do than how I feel ... at this point though I feel like there's something wrong in my practices.
I think you're wrong. You knew what to do in the past (you told us so) yet you fail at similar tasks today. Your "brain turns to mush" and you think it's practice that's lacking? Not doing TDD? Too many templates? Not knowing the latest design pattern?
One important thing to keep in mind is that progress doesn't always feel like progress. Trying something that turns out not to work might feel like a waste of time, but it's actually progress: now you know this doesn't work and you can try something else that is more likely to work. As long as you remember what didn't work and don't end up in loops where you keep trying the same non-working thing over and over again (which is harder than it sounds) you will sooner or later get it to work.
Hm, trying to load a huge ball of spaghetti code into your head is maybe not the best idea.
Personally I would only try to understand the parts I currently need.
Yes, in theory it would be nice to understand everything before you start. It would also be nice to understand quantum physics, and all sorts of other things. In real life, though, sometimes you have to compromise.
I've had the same experience with specifications, btw. Yes, I'll read the whole document before starting. But usually I only really understand it once I start implementing the details. (I am also not convinced that specs of several hundred pages are any use at all).
And then I try it, but it doesn't work because I still didn't understand the existing code. Rinse, repeat.
However, just the other week I decided somehow to FIGURE OUT HOW IT ALL WORKS, DAMMIT. I actually kept a glass of ice cubes next to my desk and pressed one to my head if I felt I was drifting, which worked surprisingly well. I realized that this codebase always had a lot of the functionality I had always wanted, hidden away in a particular method. I'd been staring right at it for months and it didn't click in my head.
I felt ashamed.