As to the question of "how to remember specificly how to code something", I have one suggestion. And that is to keep, filed in some well-organized fashion, all the code you ever write. In the course of my job, I work with many different programming languages, sometimes within a single day. So I can remember some things but there are always some details that I can't remember. However, I can remember that I once wrote code that did that, and I can pretty easily find the code that I already wrote and then adapt it or learn again from it the details that I need. This is one reason that experience in programming, over time, can really pay off.
All the other strategies suggested above are also very useful.