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).
Big things like agreeing to start coding without requirements.
Little things like inconsistent return conventions or code disagreeing with documentation comment blocks.
People are referring me to classic coder texts like Code Complete. Okay, maybe I do need a review but I fucking read that book in the 90s. It's incredibly galling.
Reminds me of that study which found giving checklists to surgeons improved survival rates in a hospital by a significant amount. It had basic stuff on there like, "Wash your hands before operating."
My job is about as good as it gets. I believe in the work, the people are great, it's interesting and affects lots of people. The downside is the codebase is old and has problems, but I've seen far worse.
Part of me is itching to strike out on my own but if I don't have the discipline to even do halfway well at a job like this, how am I going to deal with a startup?
But maybe programming is not your real passion?
I am in a similar situation right now yet again. I saw that after a year (two years max) I get bored with my job and couldn't care less and then I start looking around, change jobs and the circle begins again.
This time I realized that I need to break out of this pattern because it is leading to nowhere. I am scared to start on my own, but maybe it is just what i need? Maybe if I am out of my comfort I will be actually forced to be active and do things instead of thinking about them and complain.
So, maybe starting on your own is something you actually need, as well?
This is serial. I've lost a couple of jobs in a row from this.
Luckily I still have a reputation earned from some years ago. Plus, I interview well. People still give me jobs.
Managers don't seem to have a response here. In my experience most managers only have one bit of information devoted to programmer ability (ROCKSTAR xor SUCKS). They have alternately told me to try harder, or threatened then fired me.
I had felt like I was deceiving employers so I took a nine month break and did an artistic project. However even with a whole day to do nothing but that, I wasn't able to achieve much. I worked with a small number of people and lef that project, and it got done, but not very well, even though it was my "full time" job. Still, I felt that I had had enough of a sabbatical, and also had made some progress in psychotherapy, so I returned to the workforce, only to run into the same problems I had before. I now think the psychotherapy was not addressing the right problems -- it's more about what I do than how I feel. And it's clear my attempt at a sabbatical didn't clear up the fundamental issues.
I have friends that are able to learn programming languages on the side or take blacksmithing courses and otherwise have full and exciting lives. In other words they have reserve energy. I am so behind on just the basic requirements for my project, I feel I can't do any of this. I schedule more and more and more and more time for work and yet still nothing gets done.
As for happiness with work; I have a pattern of working with codebases that are in great need of refactoring and I am feeling a great need to stretch out and do something more original. So that is a problem.
That said, the guy who sits next to me has enough energy to actually satisfy those needs both at work (gets managers to agree to major refactorings) and also code up some great things in his spare time. Whereas I'm perenially playing catch-up and my code is ugly.
Someone mentions this below, but, are you trying to engineer the most perfect elegant solution known to man when you could get by with something more simple?
Working with existing code that someone else wrote is harder than a new project. I've only really gotten into heavy testing in the last year or two, but having tests also improves confidence that your changes are not bringing down the entire system.
Finally, what I would say is you need to get into a habit of mentally stimulating yourself after work. I found that when I was in a rut, I thought that I was burnt out and needed to "veg out" more, but I later felt that vegging out only bred more laziness and more procrastination. Once I started to get my brain stimulated in any way, whether it was reading a book, or trying something to learn something new, the effects would carry over.
Summary, laziness breeds more laziness, and stimulation actually recharges you.
You took a sabbatical but you kept programming. That didn't address your burn out at all. You should have taken blacksmithing courses. :) It's not that they have reserve energy it's that they refresh themselves by changing modes.
Personally I'm pretty prone to burn out. I work as a developer and have lots of programming side projects I work on. My advantage is that I can sense the burn out and when it happens I stop all side projects and try to do mostly administrivia at work.
I did stay in one programming job while burned out for over 2 years (this was before I realized what was it was). I produced practically nothing in that time but the act of sitting there trying to force my way through made the burn out get gradually worse. I stepped completely away from programming for about 30 months to get over it.
Another thing that made my burnout worse at that company was that the environment was so incredibly awful. Are you sure you're actually happy where you are, or do you say that because you fear being fired again? I would have said (and if fact did tell someone) that I loved my job during those dark two years, but it was because I felt worthless and unable to get anything better. I wasn't trying to trick the person that I told, I was trying to trick myself into believing it.
Working on existing, bad quality code is the biggest nightmare for me. My philosophy is to think about a problem a lot, and write as few and as concise code as possible. Even delete code if not necessary. I am working alone on 180.000 lines of really bad quality Java code with copy-pastes, and its own 'web framework' and using all the buzzword technologies like Spring everywhere. The business requirements are not that complicated (although boring like hell) 20.000 lines of really high quality code would solve the problem I think. It has been created by 3 people for not too much money. I've reached the point that it is impossible that I can ever refactor this alone, as there is no time for that an my manager is micromanaging very much. It is extremely hard to put in new features because I have no mental model for how to do things in this 'framework' (an undocumented mess. and I've spoken with the author: he could not explain the philosophy behind it.) I am so unmotivated that I go to math/programming forums and I solve math/algorithmization problems for some fun when I should work. At the darkest times I find out math quizzes for myself or just think about P vs. NP (which is depressing as there is no chance to solve that). But I need the money, and there are not much interesting jobs where I live.
And I feel that there are people who could be a bit better at what I do now: people with very very good memory. Maintaining a huge illogical mess needs very good memory and nothing else. I don't have very good memory. That's why I love logical and conciese solutions which have 'philosophy' behind them.
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.