Download presentation
Presentation is loading. Please wait.
1
Data and Flowcharts Session
Deborah Becker
2
Agenda The programming process Data hierarchy
Assigning values to variable The three basic structures Is my program structured Exercises
3
Programming steps Understand the problem Plan the logic
Code the problem Test the program Put the program into production
4
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. Does HR want a list of full time employees or should the list include part-time as well? Should the list include contract employees? What starting date should be used to begin the query? Do they want only those who worked for the company continuously for five years or should you include those employees that may have taken family leave but returned? The programmer must not make assumptions about what the user wants. What do they want the report to look like? What data should the report include; first and last name, phone, ssn. Is all this data contained in one file or will several files need to be opened? You will need to ask the user for things link print layout and file specification data.
5
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 The programming plans each task or step of the program. You also need to determine the execution order of each step. We will use our pseudocode and flowchart tools to help us plan the order of the instructions.
6
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.
7
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
8
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. About half of your will go on to be maintenance programmers and you will become experienced documentation interpreters.
9
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 Employee Class or file attributes strFirstName strLastName strAddress strPhone strSSN sngSalary
10
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
11
Step 1 Do you Understand the Problem? Yes No 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? Task list 1. Start 2. Open employee file 3. Process records while not EOF 4. Read first record 5. If years of employment >= 4 then add to report 6. If years of employment < 4 read next record 7. If end of file = true then Print report 9. Close data file 10. End
12
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
13
Structure There are three basic structures from which all logic flows
Sequences Selection (decisions) Loops (repetition) Diagram a sequence on the boars Diagram a selection on the board Diagram a loop structure on the board
14
Structures Selection Sequence Loop IF Step 1 While yes Do this Step 2
no yes No Step 3
15
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
16
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.
17
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
18
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.
19
Example Pseudocode Do stepA Step a Do StepB If ConditionC is true then
Do StepD Else Do StepE Endif While conditionF is true Do StepG End Step a Step b If C Yes No You can have a sequence inside a selection structure or inside a loop. Programs can become very complicated but remember each structure must have one way in and one way out. Step e Step d Yes While F Step g No end
20
Are you done? Yeah! Your ready to turn on the computer.
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.
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.