I used to spend most of the time on understanding the problem clearly. Once that is done I will spend my time on naming the variables and functions I am going to use. Generally I take more time on this area (naming). Based on the problem will draw a rough draft of sequence diagram. I follow this always. It helped me a lot.