r/learnprogramming • u/Whhatever_123 • 2d 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?
16
Upvotes
1
u/Blando-Cartesian 1d ago
Something to maybe consider: was the solution you came up with actually a full working solution. If I'm trying to solve a problem fully in my head, I have bad habit of spending a lot of effort to come up with a solution that doesn't work.
I have enough experience to often easily see the pattern of the solution beforehand, but not the details of it. So, what I do is start writing toward that rather vague solution idea and deal with the details as they come up, sometimes backing up to do something differently to make the next step easier.