Earlier quoted context omitted.
Have you always had this issue, or only recently? Being burned out or overstressed can cause these symptoms.
I could get work done, don't get me wrong, it's just that it does takes me more time to complete than other developers. Sometimes I could do them faster than others. It depends. I also believe my problem could be discipline. I usually work during the night, sometimes in the morning. I choose the night because it's less distraction, but then I distract myself with reddit or IRC, and I get little done. I remember havin…
Few things:
1) Sleep on a regular schedule. Set a "go to bed" alarm. Stick to it. Makes a huge difference.
2) Exercise, even if just taking brisk walks. It directly affects concentration/attention for the rest of your day. That's fairly well-supported by studies/literature.
3) Eat right. Be careful about caffeine and sugar, as the crashes will probably hit you harder than most.
4) In general, get on a schedule. Rhythm is the key.
As far as productivity:
1) Underpromise, overdeliver. This is hugely important. If you know you're not as efficient as you want to be you have to stop telling people what they want to hear and start telling them something more accurate. Even if you were ideal, we usually underestimate software tasks.
2) Look into Pomodoro or some other interval work rhythm method. It makes it OK to take breaks by regimenting them some.
3) Use a Todo list. Try to get one impactful thing (or chunk of thing) done each day at a minimum. Look up "Big Rocks" or "Zen to Done" on Google for some good tips there.
3) Find a coach. There are ADHD and productivity coaches out there that specialize in this stuff.
4) If you can't find a coach, at least find a mentor.
5) Go talk to a doctor. You sound like you have issues to actually address. If yours are like mine, meds help. You probably also need to learn some good habits though--there's no magic solution.
You also need to work on making yourself happier and regaining your own trust back. You're way too down on yourself, and you've actually written yourself off as inherently problematic. Objectivity is good, but it can also be how you get defeated before you start.
You actually sound like I did when I didn't feel like I could even be accountable to myself. Your first challenge is to get a grip on how you work and make yourself OK with it while you get better. Everyone's different, and the important thing is to accommodate yourself effectively, not to be perfect. But first, start making yourself happy. One accomplishment a day is a good step towards that.
Last thing:
I listed a lot of stuff. Don't try to do it all at once. You'll flop hard. But start working towards it.
Since you're having work issues in particular, I'd look at sleep, Todo lists, and Pomodoro as some of the first things you try.