Professional Documents
Culture Documents
Lecture Two:
• Parameters
• Return Values
• Variable Names and the Data Dictionary
• The Three Logic Structures
Explain how to design modules and functions in terms of cohesion and coupling.
List and describe the three logic structures: sequential, decision, and loops.
2. Use the three logic structures to ensure that the solution flows smoothly from one instruction to the next, rather than
jumping from one point in the solution to another.
4. Use techniques to improve readability, including the four logic structures, proper naming of variables, internal
documentation, and proper indentation.
2. Each module has a single function, such as printing, calculating, or entering data.
4. The length of a module is governed by its function and the number of instructions to be executed to perform
that function.
1. The Control module shows the overall flow of the data through the program. All other modules are
subordinate to it.
2. The Initialization module processes instructions that are executed only once during the program, and only
at the beginning
a) Calculation modules
b) Print modules
c) Read and Data Validation modules
4. Wrap-up modules process all instructions that are executed only once during the program and only at the
end.
5. Modules in an object-oriented program may include event modules such as mouse down, mouse up, key
entry, and so on.
• Cohesion is the ability for a module to work independently from all other
modules. Each module should have a function such as data entry, printing
information, specific calculations, and so forth.
• Coupling is accomplished by some type of interface between modules that enables data
to be passed from one module to another with the minimum interruption of the modular
independence. Coupling allows for the communication between modules.
• If other modules need to use the value of a variable, the modules must be coupled through
the use of parameters or return values. All modules have knowledge of global variables.
• The actual parameter listing is the list of parameters that follows the module
name being processed in the calling module.
• The formal parameter listing is the list of parameters that follow the module name
at the beginning of the module.
• There are two ways to send data from one module to another through the use of
parameters.
• The value of the name of the function is no longer available once the
instruction has been executed
• In the case of the return value, the value is only sent out of the called
module into the calling module.
See Page # 84
Computer Science and IT | College of Computing | Hiba Al Senawi 25
Variable Names and the Data Dictionary
• There are other types of structures used to design the modules themselves.
• These structures are called logic structures, and they control the logic of the data flow though the
module.
• The instructions that make up the algorithms and the flowcharts are combinations of the four logic
structures.
1. The sequential logic structure
2. The decision logic structure
3. The loop logic structure