8 AnswersNew Answer
it's difficult to memorize all the possible ways to write code, to a point that it's actually impossible to remember it all. but there is a trick, remember the basic as much as you can and later on, everything else becomes a google search! not kiding, proffessionally, I still google how to do most things, it's a good tool and it's important to make good use of it. don't beat yourself up if you forgot something, most of the time it's just a search away!
The more you use something, the more you will remember it. So practice. But you dont have to remember, if you forgot syntax, go and check it at documentation, this will not make you bad programmer, this is completly normal and even best programmer is doing this. Programming is finding solution for problems(making plan how our application will work) not memorizing code. Code is just language(tool) we use to tell computer how to do something.
As in literally every single field existing on Earth: by practicing. Do challenges requiring various function, you won't forget them if you use them often.
Codes are just like every other texts and the good news is, YES! You can memorise them. If you want to and you think that's the best for you, then proceed
I always recommend to learn the code rather than memorizing it, but in some cases remembering the basic elements and structure of a language will help u to code faster! So as I said, looking back to your old codes to copy a line or sth could be better rather than memorize all the program that u code;)
Ok I will start doing some projects
I dont know if im missing something but i think OP wants memorise some codes which maybe block, functions of algortihms or variable declaration. I think OP isnt talking about memorising a whole programming language or their syntax... Just some codes for exams or whatever
its not easy to memorize every code,just practice it u will memorize