The primary goal of the coding phase is to translate the given design into source code in a given programming language, so that code is simple, easy to test, and easy to understand and modify. Simplicity and clarity are the properties that a programmer should strive for.
All designs contain hierarchies, as creating a hierarchy is a natural way to manage complexity. Most design methodologies for software also produce hierarchies.
In a top down implementation, the implementation starts from the top of the hierarchy and proceeds to the lower levels. First the main module is implemented, then its subordinates are implemented, and their subordinates, and so on. In a bottom up implementation, the process is the reverse.
The development starts with implementing the modules at the bottom of the hierarchy and proceeds through the higher levels unit until it reaches the top. We want to build the system in parts, even though the design of the entire system has been done. This is necessitated by the fact that for large systems it is simply not feasible or desirable to build the whole system and then test it.
When we proceed top down, for testing a set of modules at the top of the hierarchy, stubs will have to be written for the lower level modules that the set of modules under testing invoke. On the other hand when we proceed bottom up all modules that are lower in the hierarchy have been developed and driver modules are needed to invoke these modules under testing. In practice in large systems, a combination of the two approaches is used during coding.
The top modules of the system generally contain the overall view of the system and may even contain the user interfaces. On the other hand, the bottom level modules typically form the service routines that provide the basic operations used by higher level modules. A program has a static structure as well as a dynamic structure. The static structure is the structure of the text of the program, which is usually just a linear organization of statement of the program. The dynamic structure of the program is the sequence of statements executed during the execution of the program.
The goal of structured programming is to ensure that the static structure and the dynamic structures are the same. That is, statements executed during the execution of a program are same as the sequence of statements in the text of that program. As the statements in a program text are linearly organized, the objective of structured programming becomes developing programs whose control flow during execution is linearized and follows the linear organization of the program text.
In structured programming a statement is not a simple assignment statement, it is a structured statement. The key property of a structured statement, is that it has a single entry and single exit. That is, during execution, the execution of the (structured) statement starts from one defined point and the execution terminates at alone defined point. With single entry and single exit statements, we can view a program as a sequence of statements.
And if all statements are structured statements, then during execution, the sequence of execution of these statements will be the same as the sequence in the program text. Hence, by using single entry and single exit statement, the correspondence between the static and dynamic structures can be obtained.
Structured programming practice forms a good basis and guideline for writing programs clearly. A software solution to a problem always contains data structures that are means to represent information in the problem domain. That is when software is developed to solve a problem; the software uses some data structures to capture the information in the problem domain.
With the problem information represented internally as data structures, the required functionality of the problem domain, which is in terms of information in that domain, can be implemented as software operations on the data structures. Hence, any software solution to a problem contains data structures that represent information in the problem domain.
When the information is represented as data structures, the same principle should be applied, and only some defined operations should be performed on the data structures. This essentially, is the principle of information hiding. The information captured in the data structures that represent the operations performed on the information should be visible. Information hiding can reduce the coupling between modules and make the system more maintainable.a