CSC 107 - Programming for Science Lecture 16: Debugging.

Slides:



Advertisements
Similar presentations
1 ICS102: Introduction To Computing King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science.
Advertisements

Number.
Basics of Computer Programming Web Design Section 8-1.
Review of Mathematical Principles
Debugging Introduction to Computing Science and Programming I.
1 CSE1301 Computer Programming: Lecture 15 Flowcharts and Debugging.
Algorithm Design CS105. Problem Solving Algorithm: set of unambiguous instructions to solve a problem – Breaking down a problem into a set of sub- problems.
Class 1: What this course is about. Assignments Reading: Chapter 1, pp 1-33 Do in Class 1: –Exercises on pages 13, 14, 22, 28 To hand in in Class 2: –Exercises.
Ways to solve problems Top down approach – Break problem up into smaller problems Bottom up approach – Solve smaller problem and then add features – Examples:
1 CSE1301 Computer Programming: Lecture 15 Flowcharts, Testing and Debugging.
Programming Fundamentals (750113) Ch1. Problem Solving
Lecture 16: Big-Oh Notation
Chapter 3 Planning Your Solution
CSC 107 – Programming For Science. Science Means Solving Problems  Physics – How does an atom work?
Study Tips for COP 4531 Ashok Srinivasan Computer Science, Florida State University Aim: To suggest learning techniques that will help you do well in this.
Testing. Definition From the dictionary- the means by which the presence, quality, or genuineness of anything is determined; a means of trial. For software.
Programming Translators.
CSC 212 – Data Structures Lecture 20: Deques. Question of the Day How did the clerk know that the man telling the following story is a fraud? I hope you.
Humorous Asides “A journey begins with single step”
Prof. Matthew Hertz SH 1029F /
General Programming Introduction to Computing Science and Programming I.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
CSC 107 – Programming For Science. Announcements  Textbook available from library’s closed reserve.
Digital Logic Lecture 4 Binary Codes The Hashemite University Computer Engineering Department.
Question of the Day While walking across a bridge I saw a boat filled with people. Nobody boarded or left the boat, but on board the boat there was not.
Prof. Matthew Hertz WTC 207D /
Course Web Page Most information about the course (including the syllabus) will be posted on the course wiki:
My talk describes how the detailed error diagnosis and the automatic solution procedure of problem solving environment T-algebra can be used for automatic.
Humorous Asides “A journey begins with single step”
By the end of this session you should be able to...
Disarming Tests. Copyright © Houghton Mifflin Company. All rights reserved.Disarming Tests - 2 Disarm Tests Grades are what we use to give power to tests.
CSC 107 – Programming For Science. Science Means Solving Problems  Physics -- How does an atom work?
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
Problem of the Day  Why are manhole covers round?
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
CSC 107 – Programming For Science. Today’s Goal  When lecture over, start understanding pointers  What a pointer is and what it is not  Why pointers.
Making Decisions uCode: October Review What are the differences between: o BlueJ o Java Computer objects represent some thing or idea in the real.
Prof. Matthew Hertz WTC 207D /
CSC 107 – Programming For Science. The Week’s Goal.
Lecture 13: 10/10/2002CS149D Fall CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
CSC 107 – Programming For Science. Today’s Goal  Become familiar with simple arrays  Declaring an array variable  Assigning data to array entries 
CSC Programming I Lecture 6 September 4, 2002.
Developing an Algorithm. Simple Program Design, Fourth Edition Chapter 3 2 Objectives In this chapter you will be able to: Introduce methods of analyzing.
1.3 Solving Systems by Substitution. Steps for Substitution 1.Solve for the “easiest” variable 2.Substitute this expression into the other equation 3.Solve.
L061 Algorithms, Part 3 of 3 Topics Top down-design Structure charts Reading Sections , 3.3.
Programming with Loops. When to Use a Loop  Whenever you have a repeated set of actions, you should consider using a loop.  For example, if you have.
CSC Programming for Science Lecture 10: Boolean Expressions & More If ­ Else Statements.
CSC 107 – Programming For Science. Science Means Solving Problems  Physics – How does an atom work?
CSC Programming for Science Lecture 8: Character Functions.
LECTURE 20: RECURSION CSC 212 – Data Structures. Humorous Asides.
The Hashemite University Computer Engineering Department
CSC 213 – Large Scale Programming. Today’s Goal  Understand why testing code is important  Result of poor or no testing & embarrassment caused  Learn.
Data Types and Conversions, Input from the Keyboard If you can't write it down in English, you can't code it. -- Peter Halpern If you lie to the computer,
CSC 107 – Programming For Science. Announcements  Lectures may not cover all material from book  Material that is most difficult or challenging is focus.
1 CSE1301 Computer Programming: Lecture 16 Flow Diagrams and Debugging.
Today… Modularity, or Writing Functions. Winter 2016CISC101 - Prof. McLeod1.
CS 115 Lecture 5 Math library; building a project Taken from notes by Dr. Neil Moore.
CSC 107 – Programming For Science. Today’s Goal  Write functions that take & return values  How parameters declared and how we call functions  What.
CSC Programming for Science Lecture 5: Actual Programming.
Introduction to Computing Science and Programming I
Topic: Functions – Part 2
Understand the Programming Process
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
Solving Two-Step Equations
Understand the Programming Process
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
Quiz Date 1/22/19 Change For version B #5
CHAPTER 6 Testing and Debugging.
Presentation transcript:

CSC Programming for Science Lecture 16: Debugging

Question of the Day What is smallest number of matchsticks moved to make this equation valid (using roman numerals) + =

Today’s Goal Today we are going to be talking about “debugging”  What it does means and what it should mean After today, should have additional strategies to develop working solutions

Origin of the Word “Bug” KING EDWARD: So, lie thou there. Die thou, and die our fear; For Warwick was a bug that fear'd us all. -- Henry VI. Part III. Act V. Scene II. bug meant a specter, ghost, other otherworldly source of fright

Origin of the Word “Bug” (2) From late 19 th century, “bug” meant defect or problem in electronic connections First computer bug was more literal

Debugging a Program Debug program when not working properly  Could be an error in the code  Program logic could be incorrect  Design may not allow certain features Better to find a bug as early as possible  Easiest to fix when still on paper  Understood best immediately after writing it This is NOT just a programming issue  Debugging is best when starting early

Starting the Program How to start a program 1. Determine what the problem is asking 2. Come up with a good set of tests cases Test cases crucial for working programs  After all, how else can you know it works?  Include a range of different possible inputs  For each input determine the correct output

Test Cases Round decimal to nearest whole number  Input is a single decimal number  Many, many possible test cases I had 5 categories of test cases  Positive rounding up  Positive rounding down , 12.1,  Negative rounding down , ,  Negative rounding up , ,  Whole numbers -- 6, -4, 0

Begin to Develop Algorithm Much easier to start on paper  Easier to write, test, and fix Break problem up into smaller steps  Each step need not be easy or obvious  Break up test cases to create tests for these steps  Do not worry solving subproblems yet Use test cases to verify algorithm works  If it does not, go back and fix those problems

Solving Subproblems Solve each subproblem separately  Do not worry about larger problem or issues  Can break up into even smaller subproblems  Worry about code only when it is obvious Solving problems in any part of life  Solving large problems is hard  Solving small problems is not

Combining Subproblems Start coding solution  Code each subproblem separately  Add comments describing what each section does Add printfs everywhere  Use to testing code immediately after writing  First, test only the code just written  Then, test larger subproblem solution  Lastly, test the entire program

Combining Subproblems Repeat tests with each new section of code  Errors will be caught immediately  Limits region that may contain the error Compare region with design to spot errors  Add more printfs and compare against traces  Should given good idea of where error occurs  If uncertain, trace code to discover why problem occurs

More Debugging Hints Liberally print out value of variables  Give printf unique prefixes to identify them printf(“Hi! %d %c\n”, result, ch); printf(“Yo! %d %c\n”, result, ch); printf(“Whoa! %d %c\n”, result, ch); Once testing done, comment out printfs  Makes it easier if more testing needed later Keep copy of last working version  When in doubt, compare new version against old one

Your Turn Get into groups and complete daily activity

Midterm Overview Midterm results were very mixed  Max score = 91  Mean score = 83  Standard deviation = 6.18 May apply curve at end of term  Will not curve any single item Can ask me questions next week  Check web page for answers  Everyone still doing well

For Next Lecture Complete week #6 weekly assignment Enjoy the respite  Normal workload resumes next week…