Data and Flowcharts Session

Download Report

Transcript Data and Flowcharts Session

Data and Flowcharts
Session
Deborah Becker
Agenda






The programming process
Data hierarchy
Assigning values to variable
The three basic structures
Is my program structured
Exercises
Programming steps





Understand the problem
Plan the logic
Code the problem
Test the program
Put the program into production
Understand the problem!

Programs satisfy users needs



HR wants a list of employees who have been
with the company over five years
Understand what the users wants
This is the probably the most important
step in planning your program.
Plan the logic



Develop your algorithm
This is not the time to worry about the
syntax of the language
You can test the logic by creating
several records to put through your
logic structure manually
Code the Program


This is where the programmer needs to
worry about the syntax.
If the planning stage was developed
successfully the coding step will require
less time.
Test and Retest


Programs that are free of syntax errors
are not necessarily free of logic errors.
This step will require a set of test data
Production

After the testing produces clean output
the program will be ready to place into
production

Allow the user to use the program


Any good user can find any unresolved bug
in even the most error free code?
Fixing bug problems and modifying the
code is called maintenance programming.
Data Hierarchy




Database
File—(User defined type/Class)
Record—(Class Instance/object)
Field—(Attribute)


The individual pieces of data that describe
each instance of the file or class.
Character
Problem!

Write a program to collect instances of an
employee class. Print employee class list
report of those with 4 or more years of
employment.

Attributes to collect





Name (First and Last)
Address (Street, City, State, Zip)
Social Security Number
Phone Number
Years of employment
Step 1


Do you Understand the Problem?
Yes

Create your task list



Define all the steps needed to solve the problem
Don’t worry about the order of the steps until you feel
that your list is complete.
No

Ask the user questions until your know the answer
to all your questions.


Do you have a copy of the report layout?
Create your task list
Step 2


Fill in your task list
Put the task in order of operations


Fill in your flowchart symbols for each task
Construct your flowchart
Structure

There are three basic structures from
which all logic flows



Sequences
Selection (decisions)
Loops (repetition)
Structures
Selection
Sequence
Loop
Step 1
Step 2
Step 3
IF
no
While
yes
yes
No
Do this
Solving Algorithms

All problems can be solved using only
these three structures


They can be combined in infinite ways
Each must have one entrance and one exit


This make the program structured
Attaching the structures end to end is
called stacking
Step 3

Create Sample records (data)

Create two or three records.



Desk check your flow chart to make sure that
your data and logic solve the algorithm.
Add any needed structure changes.
Data records will usually be supplied with
the problem definition sheet.
Step 4

Draw the User Interface



Draw the objects from the tool box on the user
interface that you need to solve the problem
Write the object name beside each object
Indicate Attribute name if a data file is going to be
used


REMEMBER CLASS IS ANOTHER NAME FOR DATA
FILE
ATTRIBUTE IS ANOTHER NAME FOR FIELD
Step 5

Use your Flowchart Form and write your
pseudocode to the right of your
flowchart.


Remember there are no set rules—this is a
tool to help you when you begin to code
your solution.
Use structured statement form and
indentations to make the logic more
apparent.
Example
Pseudocode
Step a
Do stepA
Do StepB
Step b
No
Yes
If C
Step e
Step d
While conditionF is true
Yes
While F
If ConditionC is true then
Do StepD
Else
Do StepE
Endif
Step g
Do StepG
No
end
End
Are you done?



Completed task list (order your task)
Draw your flowchart
Desk check your data




Does the data flow into and out of your structure
correctly?
Draw your User Interface and Name your
objects
Write your pseudocode
Yeah! Your ready to turn on the
computer.