There are some rather large books written on the explanation of coding. It's not something someone can just explain in a single post on here.
When learning on your own and not having a book in front of you, I find the best thing to do is to have a clear goal of what you want to accomplish and ask for assistance in accomplishing that goal. Be sure to search google or the forum first to try and find an answer. The self-learning process is a long one and one that I'm still doing myself, but as you need to accomplish something and the questions you have get answered you will slowly learn how to write the things you need to do on your own.
That's about the best I can say about that.
Good luck to you,
RJ