Write code top-down
[…] start at the top, with main() or its equivalent, and write it as if you had all the parts already written. Get that to look right. Stub out or hard-code the parts until you can get it to compile and run. Then slowly move your way down, keeping everything as brutally simple as you can. Don’t write a line of code that isn’t solving a problem you have right now. Then you may have a chance of succeeding in writing a large, working, long-lived program.