Situation:
You have a bunch o' data. You're asked to write a program to summarize or transform the data in some way.
Actions:
Use the pattern:
Extract
Process
Output
This is a variant of the input-process-output pattern.
Explanation:
Keep the three chunks separate for
- Easy writing, debugging, and testing. Easy is Good.
- Flexibility. For example, you can change the data that's extracted, without touching processing or output.
Extract
From the original data set, extract some of the data for analysis. For example:
- Data with no errors.
- Data on students with a GPA of 2.2 or below.
- Stocks that have fallen by more than 10% in the past year.
Extract the data to an array, a worksheet, or a file.
Process
Often you'll need to use loops and the accumulator pattern.
Output
Output to a worksheet, Web page, whatevs.