A term to look into: "hyperfocus"
ADHD is sometimes talked about as being misnamed, and as more of an interest/prioritisation disorder than "attention" deficit. [1]
Urgency and other factors can help put things back at the top of the pile (which can of course bring with it all sorts of poor habits to navigate) [2]
EDIT: looks like a bunch of us all posted the same thing in tandem, I'll update this to add some refs so it's not pure duplication
[1]: https://www.scientificamerican.com/article/we-need-to-rename...
Inattention in ADHD isn't really the inability to focus, it's the inability to direct focus.
Without medication I can only focus on things that I really like or am interested in. On some days there are other topics that interest me more than programming, so it isn't that I continuously can focus on programming, but far more easy and often than concentrating on things that don't give me immediate joy.
So in general I can focus less on studying, planning, important conversations, but this is not the case when I for example study programming related things (I'll easily fall in a rabbit hole), or if the planning is about an interesting topic.
It's also why I think ADHD is such a badly named condition. You don't have an attention deficit you have an attention regulation deficit - which means sometimes you can have a surplus of attention which you (often) cannot control.
When one is diagnosed, and aware of this hyperfocus thing, one can use it very efficiently. I, for one, use it to work, with the help of an app called Focus@will, where I can set a timer, and play very loud music, so my brain is focused on the task at hand.
Some can. Others end up in jail [0], or dead [1]. I wouldn't want anyone to assume that if they have ADHD, they automatically have access to some sort of super power - it doesn't always work out like that.
Like you though, I do try to harness this as best as possible for work. Music works quite well as an aid for me too.
[0] https://www.theguardian.com/society/2022/jun/18/uk-prisoners...
Boring (in a non-judgemental sense - plain) tasks very rarely trigger it. You can kinda cheat though by adopting a new exciting system for doing X to achieve X. (You'll likely abandon the system shortly after...)