STRUCTURED PROGRAMMING
- Designing and solving a programming problem using sequence, selection and iteration control instructions are called as structured programming
- It employs a top-down design model, in which the program is divided into modules
Principles of Structured Programming
- At all times and under all circumstances, the programmer must keep the program within his intellectual grasp
- The well known methods for achieving this :
- Top-down design and construction
- Limited control structures
- Limited scope of data structures
- Major elements of structured programming
- Sequence control structure
- Selection control structure
- Iteration control structure
Rules of Structured Programming
- Code no more than one statement per line.
- Divide programs into functions.
- Functions should perform only one task.
- Variable names should be meaningful.
- Use of global variables should be avoided.
- All variables should be explicitly declared and given an initial value.
- Hierarchical data structures should be used to keep the data and program structured.
- Each function must have an initial comment
- Compound conditional statements should be limited to avoid confusion.
- Indentation should be consistent.
- When used in functions, the use of { and } should be on their own lines to demark blocks of code.
- Upper case should be used for defined static constants.
- For all keywords and variables, use lower case.
Advantages of Structured Programming
- Easy to write
- Easy to debug
- Easy to understand
- Easy to change
No comments:
Post a Comment