Lecture 2
Organising Problems
Certain organisational tools can help us to solve problems :-
1)Problem Analysis Charts – a beginning analysis of the problem
2)Structure Charts – shows the overall structure
3)IPO Chart – shows the input, the processing and the output
4)Algorithm – show the sequence of instructions comprising the solution
5)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 ResultsData given in the problem or provided by user
Data constants variables / Requirements to produce the output
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 ResultsHours
Pay Rate / Gross Pay
Processing required / Solution alternatives
GrossPay = Hours * PayRate /
- Define the hours worked
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
KEY
Circle – iteration
Diagonal line – same module used twice
Diamond - selection
TASK – 1) in pairs draw a structure chart for the Average problem
2) draw a structure chart for the Gross pay problem
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.
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