When working on a new project one of the first things you should do is gather a list of requirements of what the goals of the project actually are. It's hard to create something if you don't have any solid idea of what it is that you're creating. This list of requirements doesn't have to be hard fast - there are always changes and new requirements that pop up. But you should have a basic idea of what you're trying to do before you try to do it at least.
The process of defining your requirements however does not stop at just the initial analysis or design phases. Requirement gathering should be a continuous process throughout development and maintenance. The agile approach that I champion requires that all parts of development be flexible, including requirement gathering. This does not mean that adding new requirements should be a process you throw in at the whim of a user however. Balancing what goes into a project and what stays out, along with prioritizing between requirements is the key to avoiding scope creep and actually releasing a successful project.
There are dozens of tools you can use to keep your project data together. For the initial requirement phase I tend to like just paper. Graph paper to be specific as I find that it is useful for keeping lines neat and drawing diagrams on. However some people use a visualization tool like viso or OmniGraffle, or maybe a spreadsheet, word processing document, or wiki. Maybe just a plain text file or a bunch of sticky notes. Whatever you use, just make sure you can keep it together to reference later or find a way digitize it so that you have it in one easy and accessible place.
The way I like to start with is make a quick list of all of the tasks that your project should do (or does) and rank them by importance. When starting a new project you should focus on those features that are most important first. This gives you a nice launching point for the users to see what the project does, along with the ability to use it in a useful fashion early on. If you're doing maintenance, this list gives you the ability to focus your maintenance efforts on those areas that are most important to your customers first.
Try to make sure that there is one main thing that your program does. A goal that it helps the user achieve. Generally I like a project that can be summed up in a single sentence, even if the overall use of the application can be expanded. Something like "A program for storing test results and aggregating those results into useful information." That definition describes generically what our program does, but you can expand it to include other goals that support that main goal such as "Store a description and process of the test itself so that you have context for the result you're storing." and "Organize tests into interrelated groups that relate to a common business process."
One task that people either forget or perform incorrectly is to solicit feedback from the customer/user. Forgetting to ask the user for what they want means that you're making assumptions that could very well turn out to be incorrect. Working for weeks or months to churn out a product that the customer doesn't even want isn't a very successful project. Knowing what the customer wants will make it easier to create a product that they are willing to use and that will improve their ability to achieve their goals.
However, one important thing to note is that user's don't know what they want. I know that seems to contradict what I said earlier about asking the users what they want. Why ask them if they don't even know? The user's think they know, but often they can only tell you what they can imagine. It's up to you to not take what the user says at face value and instead think about the underlying problem they are describing, ignoring any implementation details they might have provided, and determine a way for them to achieve the real goals that they desire. Asking them how a menu should look or what buttons they want where isn't very helpful. The user isn't going to want to spend the time it takes or the research necessary to tell you exactly what would really be best for them. That will take research on your part and probably some demos or prototypes that you can show to the user and gather feedback.
Once you have a list of your prioritized goals you should sketch up a rough plan on how you can achieve them. If your in maintenance mode, maybe some of your goals are too difficult to fit into the current architecture. You need to come up with a plan for modifying the structure of the project so that your goals are achievable. You should try to remain flexible during this process as most of those goals are still loose and subject to change as business requirements or new data comes to light.
Its often difficult to keep in mind your base goal for a product when all of the nagging implementation details start to bog you down. If you ever find yourself in a situation where you're working on fixing some problem and wondering how even got to this problem, or you think it's too difficult and there must be an easier way, stop. There probably is, and you might have lost focus on your scope.