You might be a great programmer/ coder, but as far as my experience tells me, never get carried away by your instincts to sit and directly write a piece of code. Start with the algorithm first ,and then proceed towards writing the code, or you will spend double the time on the same piece of code.
Always!!
Always!!