To automate something, first you have to do it manually. Then you write code for each step. Next, you bring the little bits of code together, testing each addition as it is added. Finally, you test the entire system.
The first step to automating a process is to make sure you can do the process manually. Document each step, and make sure you can write code to do that step. Then put all the pieces together.
Many times a protégé has come to me asking for help automating something. "Oh, I've worked on this problem for hours! I'm completely stuck!" he'll say.
"OK," I reply, "show me how you would do this manually."
"I don't know. I can't figure that out."
"The root of your problem is just that, young padawan. Hmmm?"
As discussed in Chapter 12, one of the benefits of documenting a procedure is that writing down the steps is the key to being able to automate something. I wasn't kidding. In fact, when I don't have time to automate something, I write the step-by-step procedure on my Wiki telling someone else how to do the task. When I do that, I've accomplished two things. First, I've contributed to the documentation of how our system works. Second, I've actually performed the first step of automating the process!
Document the steps, then automate them. If you can't write down the steps, you'll never figure out how to automate them.
The process of writing down the steps forces you to identify all the steps. Unlike keeping all of the steps in your head, you ...