Fixing Broken Programs. How do you figure out what’s wrong? Look carefully at the error message. Locate the error – Most messages have line numbers –

Slides:



Advertisements
Similar presentations
Can you tell the letter each picture begins with?
Advertisements

Modelling & Datatypes John Hughes. Software Software = Programs + Data.
Modelling & Datatypes Koen Lindström Claessen. Software Software = Programs + Data.
CS102--Object Oriented Programming
CSE 1301 Lecture 6B More Repetition Figures from Lewis, “C# Software Solutions”, Addison Wesley Briana B. Morrison.
Using Types Slides thanks to Mark Jones. 2 Expressions Have Types: The type of an expression tells you what kind of value you might expect to see if you.
Computer Science 1620 Loops.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering 3 October 2007.
Introduction to ML - Part 2 Kenny Zhu. What is next? ML has a rich set of structured values Tuples: (17, true, “stuff”) Records: {name = “george”, age.
Loops Repeat after me …. Loops A loop is a control structure in which a statement or set of statements execute repeatedly How many times the statements.
BB1756: Software Development Functional Programming in Haskell 2010/2011 Dan Russell WWW:
Programming 1 Tim Sheard. Spring Quarter Goals of the class – Learn to write simple programs using the programming language Haskell. – Learn by example.
Arrays. A problem with simple variables One variable holds one value –The value may change over time, but at any given time, a variable holds a single.
The If/Else Statement, Boolean Flags, and Menus Page 180
0 PROGRAMMING IN HASKELL Chapter 3 - Types and Classes.
Arrays. A problem with simple variables One variable holds one value –The value may change over time, but at any given time, a variable holds a single.
Using Types Slides thanks to Mark Jones. 2 Expressions Have Types: The type of an expression tells you what kind of value you might expect to see if you.
CIT 590 Unit testing. Agenda Debugging attempt 2 (because I am stubborn) What is unit testing Why? Unit testing framework in Python.
Lets begin, next Instruction Read each question and answer by clicking the correct answer. Lets go.
Introduction to Python Lecture 1. CS 484 – Artificial Intelligence2 Big Picture Language Features Python is interpreted Not compiled Object-oriented language.
1 Copyright (C) 2008 by Dennis A. Fairclough all rights reserved.
 For Loops › for (variable set; condition; incremental or decrement){ // loop beginning › } // loop end  While loops › while (condition) { // beginning.
TUTORIAL 00 Resources and Course Review. a00q4.rkt (define my-tutorial-info (list ………))
Functions in C. Consider #include main() { int i; for(i=1; i
Java Data Types. Primitive Data Types Java has 8 primitive data types: – char: used to store a single character eg. G – boolean: used to store true or.
CS1 Lesson 2 Introduction to C++ CS1 Lesson 2 -- John Cole1.
Variables Tutorial 3c variable A variable is any symbol that can be replaced with a number to solve a math problem. An open sentence has at least one.
Lists. Container Classes Many applications in Computer Science require the storage of information for collections of entities e.g. a student registration.
Introduction to C++ // Program description #include directives int main() { constant declarations variable declarations executable statements return.
5 BASIC CONCEPTS OF ANY PROGRAMMING LANGUAGE Let’s get started …
CS102 Introduction to Computer Programming Chapter 4 Making Decisions.
1 C++ Programming Basics Chapter 2 Lecture CSIS 10A.
Constants Numeric Constants Integer Constants Floating Point Constants Character Constants Expressions Arithmetic Operators Assignment Operators Relational.
File Input and Output in C++. Keyboard and Screen I/O #include cin (of type istream) cout (of type ostream) Keyboard Screen executing program input data.
College Board A.P. Computer Science A Topics Program Design - Read and understand a problem's description, purpose, and goals. Procedural Constructs.
Making Decisions (True or False) Relational Operators >greater than =greater than or equal to
Scope When we create variables and functions, they are limited in where they are visible and where they can be referenced For the most part, the identifiers.
CS161 Topic #16 1 Today in CS161 Lecture #16 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for)
Two-Dimensional Arrays That’s 2-D Arrays Girls & Boys! One-Dimensional Arrays on Steroids!
Variables and Data Types.  Variable: Portion of memory for storing a determined value.  Could be numerical, could be character or sequence of characters.
Conditional Statements.  Quiz  Hand in your jQuery exercises from last lecture  They don't have to be 100% perfect to get full credit  They do have.
Exceptions Chapter 16 This chapter explains: What as exception is Why they are useful Java exception facilities.
Introduction to Loops Iteration Repetition Counting Loops Also known as.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Lecture 3 Introduction to Computer Programming CUIT A.M. Gamundani Presentation Layout from Lecture 1 Background.
Agenda Perform Quiz #1 (20 minutes) Loops –Introduction / Purpose –while loops Structure / Examples involving a while loop –do/while loops Structure /
Introduction to Objective Caml. General comments ML is a purely functional language--there are (almost) no side effects There are two basic dialects of.
Errors in Numerical Methods
1 CSC 1111 Introduction to Computing using C++ C++ Basics (Part 1)
Solving Problems with Repetition Version 1.0. Objectives At the end of this topic, students should be able to: Correctly use a while statement in a C#
Learning Javascript From Mr Saem
Variables, Types, Operations on Numbers CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Computer Skills2 / Scientific Colleges 1 Arrays Topics to cover: Arrays Data Types One-dimensional Arrays Two-dimensional Arrays.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
Chapter # 2 Part 2 Programs And data
Java for Beginners University Greenwich Computing At School DASCO
Chapter 5: Control Structures II (Repetition)
Haskell Chapter 2.
Lecture 4B More Repetition Richard Gesick
Arrays, For loop While loop Do while loop
Computers & Programming Languages
More Loops.
More Loops.
C++ Data Types Data Type
Recap Week 2 and 3.
Chapter # 2 Part 2 Programs And data
2. Second Step for Learning C++ Programming • Data Type • Char • Float
Unit 3: Variables in Java
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Data Types and Maths Programming Guides.
Presentation transcript:

Fixing Broken Programs

How do you figure out what’s wrong? Look carefully at the error message. Locate the error – Most messages have line numbers – Comment out the part of the program where you think the error may be. Then add in little bits at a time, until it breaks again. Try and fix it yourself Ask some one for help.

Where is the error The error message tells the file and the line number It also tells what it thinks is wrong. It is not always correct.

Line number analysis Errors are some times on the line indicated Many times the errors are in the last non- whitespace before the line number listed. This can be several lines above the line number indicated.

Num class errors When you write a numeral – 5 – 22 – 1567 etc The system classifies this a value in the Num class – This means it could be Int, Integer, Double, Float, or many other types. An error that mentions (Num x) could mean you have a numeral without an exact type. Use a type declaration to fix this x::Integer r = row [x] r = row [5:: Integer] r = row [5] Broken program Fix #1 Fix #2

Constructor errors Constructors start with a capital letter – We know of at least two- True and False – Types also start with a capital letter: Bool, Integer, Double, etc. You cannot use a name that starts with a capital letter. If you see “unexpected Constructor” look for a name that starts with a capital letter.