The following list summarizes some of the rules you should follow to make routines as useful as possible:
Perform a single, well-defined task
Avoid side effects
Use descriptive names
Keep it short
The following sections describe these concepts.
If a routine performs a single, well-defined task, it is easy for programmers to understand what it does and use it correctly. If a routine performs more than one task, programmers may be unable to perform one of the tasks without performing the other. They also may confuse the tasks and not use them properly.
If a piece of code performs multiple unrelated tasks, break it into separate routines, each of which will perform a single task. The code ...