I have been wondering about the best way to learn playing a new song on guitar. For example, a lot of people try to pick a small part, practice and perfect it and then repeat the procedure for the rest of the song.
Breaking pieces into small sections and practising them until you can play them well is probably the best way of learning a new piece.
However, you'll also need to work on linking these sections together so it doesn't sound too disjointed - you don't want to get too used to stopping at a certain point! To get around this, it's also a good idea to practise the entire piece all the way through slowly after you've got most of the sections right. Eventually you can speed up to get to the normal tempo.
Nobody can answer this for you - everyone has a different learning style, and you are going to have to find out what works best for you.
Some people would prefer to be able to bluff their way through a whole song first - improvising approximate versions of riffs or just strumming chords - before picking out sections to refine.
Other people prefer to perfect bar 1 before moving on to bar 2, and so on.
Personally, I've had teachers who make you repeat a riff for a whole lesson, then never actually go on to perform the whole song. That drives me mad. I'd much prefer to play a whole song badly, than learn one riff and do nothing else with it.
If you can get or make a recording of it and listen to it over and over again, that's what helps me. When I'm actually playing, I usually hear the whole song or piece in my head - all the parts, all the sections, etc, and I just follow along with what's in my head.
Clearly that method breaks down when I'm working with others on writing a song. In those cases I count measures or repeats out loud and might even call changes out for everyone's benefit (including mine). Having a white board around to write the changes down on to have them large and clearly readable helps during writing (or learning). I'll also use software to make little demo versions which help me learn the structure and also see areas of weakness or come up with ideas.
In terms of how I learn right off the bat, I usually start at the beginning and work my way to the end. Tricky parts will get extra attention. I don't like to get in the habit of only working a section at a time because transitions are key so I like to try to keep it unified with smooth changes from section to section.