Yep. I do a few things to help stop this:
1) When I first start coding I’ll just write out (like, in english) what I want the code to do.
2) I break the code up into ‘logical pieces’ and just work on 1 piece at a time
3) use descriptive names for varianbles and methods. Don’t have amthod called mymethod() or a variant called “A” “words” and “Secntence” or “breakasentenceintowords()” are better descriptions.
You’ll also get better at coding the more you do it. So as time goes on it’ll be less of an issue.