12.2.2 Parameters, Interfaces and Control in Structure Charts
A structure chart does more than show how a program is divided into modules. It can also show the information passed between those modules and indicate when a module is selected or repeated.
This section adds parameter and control notation to the hierarchical designs introduced in the previous section. The resulting chart provides a more precise plan for the procedures and functions that may later appear in pseudocode.
By the end of this section, you should be able to:
- Explain the purpose of a module interface.
- Identify parameters supplied to and returned from modules.
- Distinguish data parameters from control information.
- Interpret Boolean flags and updated-value notation.
- Explain how selection and repetition are represented.
- Add suitable interface and control information to a structure chart.
From Module Hierarchy to Module Communication
Decomposition identifies the modules needed by a solution. The next design question is how those modules obtain the information required to perform their tasks.
Consider a module called CheckLoanEligibility. The name tells us its
responsibility, but it does not tell us:
- which member is requesting the loan;
- which item has been selected;
- how many days the item is needed;
- what decision the module produces.
Parameter labels and arrows make these relationships visible.
Parameters in a Structure Chart
Parameters allow a module to perform a general task using values provided by another part of the program. For example:
CheckLoanEligibility
receives: MemberID, ItemCode, LoanDays
produces: LoanAllowed, RejectionReason
The eligibility module does not need to collect the values itself. Its responsibility is to use the supplied values to make a decision.
| Parameter | Example value | Why the module needs it |
|---|---|---|
MemberID |
"M482" |
To locate the member's loan status |
ItemCode |
"DRL-07" |
To identify the requested equipment |
LoanDays |
5 |
To check the requested duration |
LoanAllowed |
TRUE |
To communicate the result to the calling module |
Parameters and arguments
In a structure chart, a label normally identifies a parameter in the planned interface. When pseudocode calls the module, the actual value or expression supplied is an argument.
CheckLoanEligibility(CurrentMember, SelectedItem, RequestedDays)
Here, the interface may define parameters named MemberID,
ItemCode and LoanDays, while
CurrentMember, SelectedItem and
RequestedDays are the arguments used in one particular call.
Interfaces Between Modules
A well-designed interface makes a module easier to understand because its required inputs and produced results are explicit.
| Interface question | Equipment-loan example |
|---|---|
| What does the module need? |
CheckLoanEligibility needs a member identifier, item code
and requested duration.
|
| What does the module produce? | It produces a Boolean decision and, when required, an explanatory message. |
| Which details remain internal? | The exact search steps used to find the member record do not need to appear in the higher-level interface. |
| Which module uses the result? |
The coordinating module uses LoanAllowed to select the next
action.
|
An interface should expose the values needed for communication without exposing every local variable used inside the module.
Following Parameter Directions
The arrow direction shows whether a value is supplied to a lower-level module or returned to the higher-level module.
| Direction | Meaning | Example |
|---|---|---|
| Downward | The higher-level module supplies a parameter to the lower-level module. |
MemberID, ItemCode and
LoanDays are supplied to
CheckLoanEligibility.
|
| Upward | The lower-level module supplies a result to its parent. |
LoanAllowed and RejectionReason are returned
to ProcessToolLoan.
|
| Both directions | A value is supplied to a module, changed there and returned. |
AvailableUnits is passed to ReserveItem and
returned with its updated value.
|
LoanDays is passed down to
CheckLoanEligibility.β
Data Values and Control Information
Most parameters represent data that a module processes, such as an identifier, quantity, date or calculated result. A structure chart can also show a control value that influences which module is called or whether work is repeated.
| Information type | Purpose | Example |
|---|---|---|
| Data parameter | Carries a value to be stored, checked, calculated or displayed. | ItemCode, LoanDays, LoanReference |
| Control flag | Communicates a state that affects control decisions. | LoanAllowed, MoreRequests |
| Updated parameter | Carries a value into a module and returns its changed value. | AvailableUnits |
TRUE/FALSE or
available/not available.
In some structure-chart conventions, an arrow with a filled circular end identifies a control flag. A question may provide its own symbol key, which should always be followed.
Showing Selection
Selection is needed when a condition determines which one of several module calls should occur.
In the equipment-loan system:
IF LoanAllowed = TRUE
call CreateLoan
ELSE
call DisplayRejection
ENDIF
A structure chart can represent this choice using a diamond or selection marker connected to the alternative modules. The condition should be labelled clearly.
| Selection element | Equipment-loan interpretation |
|---|---|
| Control flag | LoanAllowed |
| Condition | LoanAllowed = TRUE? |
| True branch | Call CreateLoan |
| False branch | Call DisplayRejection |
LoanAllowed flag determines whether the system calls
CreateLoan or DisplayRejection.β
Showing Repetition
Repetition notation indicates that one module or a group of modules is called more than once while, or until, a condition is satisfied.
An equipment desk may process requests until its queue is empty:
WHILE MoreRequests = TRUE
ReadNextRequest
ProcessToolLoan
CheckForMoreRequests
ENDWHILE
A curved or semicircular arrow may be drawn over the repeated modules. Its label identifies the repetition condition.
| Repetition element | Meaning |
|---|---|
| Repeated group |
ReadNextRequest,
ProcessToolLoan and
CheckForMoreRequests
|
| Control flag | MoreRequests |
| Condition | Repeat while MoreRequests = TRUE |
Values That Are Updated by a Module
Sometimes a module receives a value, changes it and makes the updated value available to its parent. A double-headed arrow can be used to represent this two-way movement.
Suppose the system stores how many units of a tool remain available:
ReserveItem receives AvailableUnits
ReserveItem subtracts 1
ReserveItem returns the updated AvailableUnits
| Before the call | Module action | After the call |
|---|---|---|
AvailableUnits = 4 |
ReserveItem accepts one loan |
AvailableUnits = 3 |
AvailableUnits is passed to ReserveItem, reduced when the
reservation succeeds and returned to the parent module.β
Worked Example: Community Equipment Loan
A community workshop lends tools to registered members. A loan request contains a member identifier, an item code and the number of requested days.
The system must:
- read the request;
- check the member, item and requested duration;
- create a loan when the request is allowed;
- show a rejection reason when it is not allowed;
- update the number of available units after a successful reservation.
Modules and interfaces
| Module | Parameters received | Values produced or updated |
|---|---|---|
ReadLoanRequest |
None from its parent |
MemberID, ItemCode,
LoanDays
|
CheckLoanEligibility |
MemberID, ItemCode,
LoanDays
|
LoanAllowed, RejectionReason
|
ReserveItem |
ItemCode, AvailableUnits |
Updated AvailableUnits |
CreateLoan |
MemberID, ItemCode,
LoanDays
|
LoanReference |
DisplayConfirmation |
LoanReference, AvailableUnits |
None |
DisplayRejection |
RejectionReason |
None |
Control design
| Control feature | Design decision |
|---|---|
| Selection |
If LoanAllowed is true, reserve the item, create the loan
and display confirmation. Otherwise, display the rejection reason.
|
| Updated value |
AvailableUnits enters ReserveItem and returns
with its reduced value.
|
| Repetition |
The complete request process repeats while
MoreRequests is true.
|
Text representation of the design
ProcessLoanQueue
βββ WHILE MoreRequests
βββ ReadLoanRequest
β βββ returns MemberID, ItemCode, LoanDays
βββ CheckLoanEligibility
β βββ receives MemberID, ItemCode, LoanDays
β βββ returns LoanAllowed, RejectionReason
βββ IF LoanAllowed
βββ ReserveItem
β βββ updates AvailableUnits
βββ CreateLoan
β βββ returns LoanReference
βββ DisplayConfirmation
ELSE
βββ DisplayRejection
How to Read an Annotated Structure Chart
Read a chart systematically rather than trying to understand every symbol at once.
- Identify the parent module. Determine which broad task is coordinating the lower modules.
- Identify its children. State the responsibilities of the called modules.
- Trace downward parameters. Find the values supplied to each child.
- Trace upward parameters. Find results returned to the parent.
- Identify control flags. Determine how Boolean results influence the design.
- Interpret selection and repetition. State which modules are conditional or repeated.
- Locate updated values. Explain any double-headed parameter arrows.
Adding Interfaces and Control to a Chart
Begin with the module hierarchy. Then annotate it using the information required by each module.
- List each module's required inputs. Ask what the module must know before it can perform its task.
- List each result. Ask what information another module needs after the task is complete.
- Draw and label parameter arrows. Show supplied values and returned results clearly.
- Identify Boolean decisions. Decide whether a returned flag controls a selection or repetition.
- Add selection notation. Label the condition and its alternative branches.
- Add repetition notation. Identify the repeated group and its continuation or stopping condition.
- Mark updated parameters. Use two-way notation where a supplied value is changed and returned.
- Check the chart. Ensure that every parameter is created before it is passed and used by a module that needs it.
Interactive: Structure Chart Interface Explorer
Switch between data passing, selection, repetition and an exam-style challenge. Select any module to inspect its inputs, outputs and control role.
Common Mistakes and Misconceptions
- Leaving arrows unlabelled. A connection without a parameter name does not clearly define the interface.
- Reversing parameter direction. Check whether the child receives a value or produces it.
- Showing local variables as interface parameters. Only values crossing module boundaries need to appear.
- Confusing a flag with ordinary data. Explain which decision or repetition the flag controls.
- Using a selection diamond as a module. The diamond represents a condition that chooses between module calls.
- Leaving repetition unlabelled. State when the repeated group continues or stops.
- Assuming a double-headed arrow specifies pass by reference. It shows an updated value at the design level, not a language-specific mechanism.
- Showing parameter flow but no module hierarchy. A structure chart must still show parent and child relationships.
Practice
Core questions
- Define the term parameter.
- Explain what is meant by a module interface.
- Explain the difference between a downward and upward parameter arrow.
- Explain the purpose of a Boolean flag in a structure chart.
- Explain how a structure chart can represent selection.
- Explain how a structure chart can represent repetition.
- Explain the meaning of a double-headed parameter arrow.
- Explain why local variables do not normally need to appear on the interface.
Scenario A: Bicycle-Service Booking
A program reads a customer identifier, bicycle type and requested service. It checks whether the service can be completed on the selected date. An accepted booking produces a reference; a rejected booking produces a reason.
- Suggest a suitable top-level module.
- Suggest modules for input, checking, booking and output.
- List the parameters received and produced by each module.
- Identify a suitable Boolean control flag.
- Show the selection between confirmation and rejection.
- Draw the annotated structure chart.
Scenario B: Community Hall Capacity
A program repeatedly reads group bookings while more requests remain. It checks
whether enough seats are available. Accepted bookings reduce the value
SeatsAvailable.
- Identify the repetition flag.
- Identify the selection flag.
- Identify the value that is updated.
- State which modules receive and return each value.
- Draw a structure chart containing repetition, selection and a double-headed arrow.
Review
| Prompt | A strong response should include |
|---|---|
| Parameter | A named value passed through a module interface. |
| Interface | The defined connection through which modules exchange values. |
| Downward arrow | A value supplied by a higher-level module to a lower-level module. |
| Upward arrow | A result supplied by a lower-level module to its parent. |
| Control flag | A Boolean value used to influence selection or repetition. |
| Selection | A labelled condition that chooses between alternative module calls. |
| Repetition | A labelled control symbol showing that modules are called repeatedly. |
| Double-headed arrow | A value is supplied to a module, updated and returned. |