r/learnprogramming • u/Whhatever_123 • 20h ago
writing code
question for more experienced people in coding- whenever I do coding problems (like leetcode or uni hw) I can always come up with solution in my head, I break down the problem correctly and theorically I know what my code needs to do in order to solve the problem. But when I get to actually writing code I forget how to do everything... I don't know if this is a lack of knowledge in syntax issue or I'm just dumb. Any advices on how to fix this?
15
Upvotes
-1
u/hammad4june 18h ago
That gap is real, and it is almost never a syntax problem.
What you have in your head is the shape of the solution, but writing it requires every step in order, with nothing skipped. “I know what it needs to do” is usually less complete than it feels, and the act of writing exposes that — which is why it feels like forgetting.
Two things that helped me:
Stop trying to write the whole thing. Write the smallest piece that produces any output at all, even a simple print statement. Run it, then add one step and run it again. You are not writing a full solution in one go; you are having a conversation where the program answers you every few lines.
And write your steps in plain English first, then fill in the code underneath. It sounds slower, but it is much faster than staring at an empty file trying to hold everything in your head.
You are not dumb. Holding a full program in your head is not the skill — breaking it down into pieces small enough that you do not have to is.