Every program should have a design, or plan, for the programmer to follow. In the parlance of the programmer, every program needs an algorithm. Simply stated, an algorithm is a statement of a systematic means for solving a specific problem. To programmers, an algorithm is the blueprint, or recipe, that we follow to produce a program.
Macro Versus Micro Algorithms
Algorithms come in different flavors. We can talk about the algorithm used to write a given program. At this level, we're talking about algorithms at the macro level. The algorithm tries to capture the general aspects of the program as an overview rather than grapple with the nitty-gritty details of each aspect of the program.
We can also discuss an algorithm at the micro level. At this level, we get down to the nuts, bolts, and glue that hold one particular aspect of the program together. For example, if you have data that must be sorted before it can be used, there are dozens of sorting algorithms from which to choose. Selecting one sorting algorithm addresses one aspect of the program. Once you've sorted the data, you need another micro algorithm to display the data.
As you might guess, we can collect all the micro algorithms to create a macro algorithm. If we start with the micro algorithms and work up to the macro view of the program, we're doing what's called bottom-up program design. If we start with a macro algorithm and work down toward the micro algorithms, we're doing top-down program design.
So, which method is best? If you take all the articles that have been written on which design approach is better and laid them end-to-end, you would never reach a conclusion. Each approach has its good points and bad points.
Regardless of which design approach you use, you must have some design for the program. At the very least, you need a statement of the programming problem at hand and a plan for addressing the problem. Once you understand the problem, you can start figuring out how to solve it. You'd be amazed how many false starts I've seen because the users and the programmers did not communicate the problem to be solved.
Because I believe a solid understanding of the problem to be solved is an essential first step in programming, I might favor the top-down program design approach. With that in mind, let's use a macro approach to viewing virtually every programming problem.