Lecture 2 Structure Charts

advertisement
Lecture 2
Organising Problems
Certain organisational tools can help us to solve problems :1)
2)
3)
4)
5)
Problem Analysis Charts – a beginning analysis of the problem
Structure Charts – shows the overall structure
IPO Chart – shows the input, the processing and the output
Algorithm – show the sequence of instructions comprising the solution
Flowcharts – graphic representations of the algorithms
These tools can be used to help make the final program more readable and efficient
Problem Analysis Chart (p41)
Good way to analyse a problem – separates the problem in 4 parts
Given Data
Required Results
Requirements to produce the output
Data given in the problem or provided by
user
Data constants variables
Processing required
Solution alternatives
Lit of processing required – equations, or
searching or sorting techniques
List of solution alternatives
TASK :- 1) In Pairs create a Problem analysis chart for the average problem
2) Individually – create a Problem Analysis chart for calculating the Gross
pay , given the formula GrossPay = Hours * PayRate
Given Data
Required Results
Gross Pay
Hours
Pay Rate
Processing required
GrossPay = Hours * PayRate
Solution alternatives
1. Define the hours worked
And pay rate as constants
2. Define the hours worked and pay rate
as input values
Structure Chart (p43)
This breakdowns a complex problem into simpler tasks.
This divides your solution in modules – subtasks. Structure charts connect modules
together to show the interaction of processing between the modules
Each module should contain the tasks to finish accomplish one function - .g calculating
results
The control module controls the flow to other modules
control
Module 1
Module 3
Module 2
Module 6
KEY
Circle – iteration
Diagonal line – same module used twice
Diamond - selection
Module 3
Module 7
Module 4
Module 5
TASK – 1) in pairs draw a structure chart for the Average problem
2) draw a structure chart for the Gross pay problem
Payroll
Control
Read
Cala
Print
Event-driven / object-oriented programming structure chart
Before graphical user interface all solutions were procedural in nature. Solutions were
developed using a Top-down method, here the program was executed form beginning to
end. The user did not control the order of execution of the modules. The program was in
control
In object-oriented programming – which is event driven – the user is in control. Modules
are still used, within each module the execution is procedural. The difference lies in that
the user decides order of execution of the module.
Module6
Module7
Module3
Module3
Module2
Module1
Module4
Control
Module5
A structure chart for an object oriented programming solution. Show the subtask modules
surrounding the control module. The subtasks modules are called when an event is
initiated.
TASK – 1) In Pairs – Draw a Object oriented structure chart solution for Average
problem
2) Draw a Object oriented structure chart solution for Payroll
Read
PayrollControl
Calc
Print
Download