I remember the first time that I made a program, I was using Turing and had learnt a few methods so I jumped right in and made the program which happed to be a "hello world". Later on when bigger projects came up and I started using Java, I found it hard to actually just jump in and get a program to work, multiple revisions are needed before you get to the bottom of the stupid mistake you did on line whatever. I learnt the hard way that one must first plan out what one will do before one even touches the keyboard. As I said before you can plan a simple program in your mind but theres a limit to that.
This is when you sit your self down, whether it be at coffee shop, pub, at home, or in a park, take out your medium(for me its a white board, but it can be whatever you have at hand to write on) and think. Some of the things that you have to think about are:

What is your program supposed to do? *Very important

How your going to get your program to do what you want it to do?

Is it worth making the program from scratch?

Has someone else maybe done something similar that you could take something from their code and implement it into your own?
Some people might disagree that not using 100% your own coding is wrong, but if that person has given their consent and you mention them in the program, then why not? I'm NOT saying that you should steal someones code and says its your own , by no means. That would be plagiarism, and wrong. I'm saying if someone did the work already and has post it so that others may use it why not?

Also think about how your going to update you program?(VERY IMPORTANT for Websites and databases)
After all that thinking and writing you'll probably have a very solid guideline as to how to actually write all the code for the program. This will probably save you a good measure of time and frustration, you would have otherwise spent pounding at your keyboard.