Organizing and Reusing Code

When you sit down to write a script that will do something useful, chances are your code is going to get a bit more complex. As you add more and more code, it becomes harder and harder to read it all in one chunk. If printed on paper, your script would probably stretch across multiple pages. As the code gets more and more complex, it becomes easier and easier for bugs to creep in, which makes it harder and harder to find and fix those bugs. The most common technique that programmers use to manage complexity is called modularization. That's a big, fancy word, but the concept is simple really.