4 introduction to programming structure

11
Introduction to Programming Structure *Property of STI Page 1 of 11 Data Structures and Algorithms Pointers for Structuring a Program 1. Use Modules 2. Use the four logic structures a. Sequential Structure b. Decision Structure c. Loop Structure d. Case Structure 3. Eliminate the rewriting of identical processes by using modules 4. Use techniques to improve readability, including the four logic structures, proper naming of variables, internal documentation, and proper indentation

Upload: rheigh-henley-calderon

Post on 02-Nov-2014

25 views

Category:

Technology


1 download

DESCRIPTION

 

TRANSCRIPT

  • 1. Data Structures and AlgorithmsPointers forStructuring aProgram1. Use Modules2. Use the four logic structuresa.Sequential Structureb.Decision Structurec.Loop Structured.Case Structure3. Eliminate the rewriting of identical processes by using modules4. Use techniques to improve readability, including the four logic structures, proper naming of variables, internal documentation, and proper indentationIntroduction to Programming Structure *Property of STI Page 1 of 11

2. Data Structures and AlgorithmsCohesion andCouplingCohesion @ relates to the functional independence of themodule and to the performance of a single taskwithin the moduleCoupling @ allows modules to be connected by an interface,which enables the programmer to transfer datafrom one module to another.Introduction to Programming Structure *Property of STI Page 2 of 11 3. Data Structures and Algorithms ModulesRules in Designing Modules 1. Each module is an entity itself. 2. Each module has a single function. 3. Each module is short enough to be easily read andmodified. 4. The length of a module is governed by its functionand the number of instructions to be executed toperform that function. 5. A module is developed to control the order ofprocessing.Introduction to Programming Structure*Property of STIPage 3 of 11 4. Data Structures and Algorithms ModulesTypes of Modules1. Control Module2. Initialization Module3. Process Data Module a. Calculation Modules b. Print Modules c. Read and Data Validation Modules4. Wrap-up module5. Event Modules (OO-Paradigm)Introduction to Programming Structure*Property of STIPage 4 of 11 5. Data Structures and Algorithms Local and Global VariablesLocal Variables@ may be used only by the module itselfGlobal Variables@ they are global to the program as they can be seen by all modulesIntroduction to Programming Structure*Property of STIPage 5 of 11 6. Data Structures and AlgorithmsParametersParameters@ local variables that are passed or sent from onemodule to another. Parameters are another wayof facilitating coupling that allows thecommunication of data between modulesCalling Module@ the module that processes another moduleCalled Module@ the module being processedIntroduction to Programming Structure*Property of STIPage 6 of 11 7. Data Structures and AlgorithmsParametersActual parameter listing@ the list of parameters that follows the modulename being processed in the calling moduleFormal Parameter Listing@ the list of parameters that follow the modulename at the beginning of the moduleIntroduction to Programming Structure *Property of STI Page 7 of 11 8. Data Structures and AlgorithmsParametersTypes of parameter passinga Call by valuea Call by referenceIntroduction to Programming Structure*Property of STIPage 8 of 11 9. Data Structures and AlgorithmsParametersIntroduction to Programming Structure*Property of STIPage 9 of 11 10. Data Structures and AlgorithmsParametersIntroduction to Programming Structure*Property of STI Page 10 of 11 11. Data Structures and Algorithms Variable Names and Data Dictionary The Four Logic Structures Sequential Decision Loop CaseIntroduction to Programming Structure*Property of STI Page 11 of 11