Same way you get to Carnegie Hall: Practice, practice, practice. Oh, and then practice some more.
There's no magic way. Find a good book or good tutorial site and read, read, read. And then code, code, code.
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.