I have written hundreds of programs and when writing each new program, I think about how to do this and how to do that, and then start writing the program. I then spend some time in debugging or modifying it whenever it becomes necessary. I think that, I need to have a better methodology. How do you write the program, regardless of programming task or programming languages?