Review. Errors. Ø Users may enter data in the wrong form Ø Files may not exist Ø Program code has bugs!*

Size: px
Start display at page:

Download "Review. Errors. Ø Users may enter data in the wrong form Ø Files may not exist Ø Program code has bugs!*"

Transcription

1 Objectives Exceptions Ø Why Exceptions? Ø Throwing exceptions Packages Javadocs Eclipse Log into your machines Review How do we specify that a class or a method cannot be subclassed/overridden? Compare and contrast abstract classes and interfaces When should a class be abstract? Ø If you extend an abstract class, do you have to override all abstract methods? When should you create/use an interface? What is the keyword for defining your class to adhere to an interface? Sept 25, 2013 Sprenkle - CSCI209 1 Sept 25, 2013 Sprenkle - CSCI209 2 Review: Using an Interface or Abstract Class Interfaces ü Any class can use ü Can implement multiple interfaces No implementation - Implementing methods multiple times - Adding a method to interface will break classes that implement Abstract Classes Contain partial implementation - Can t extend/subclass multiple classes ü Add non-abstract methods without breaking subclasses Sept 25, 2013 Sprenkle - CSCI209 3 Iteration over Code Assignment 4 à Assignment 5 Demonstrates typical design/implementation process Ø Start with your original code design Inheritance from GamePiece class Ø Realize it could be designed better Make GamePiece class abstract Use an array of GamePiece objects Easier to add new functionality to Game Major part of problem-solving is figuring out how to break problem into smaler pieces Sept 25, 2013 Sprenkle - CSCI209 4 EXCEPTIONS Errors Programs encounter errors when they run Ø Users may enter data in the wrong form Ø Files may not exist Ø Program code has bugs!* When an error occurs, a program should do one of two things: Ø Revert to a stable state and continue Ø Allow the user to save data and then exit the program gracefully * (Of course, not your programs) Sept 25, 2013 Sprenkle - CSCI209 5 Sept 25, 2013 Sprenkle - CSCI

2 Java Method Behavior Normal/correct case: return specified return type Error case: does not return anything, throws an Exception Ø An exception is an event that occurs during execution of a program that disrupts normal flow of program's instructions Ø Exception: object that encapsulates error information Similar to Python Sept 25, 2013 Sprenkle - CSCI209 7 Handling Exceptions JVM s exception-handling mechanism searches for an exception handler the error recovery code Ø Exception handler deals with a particular exception Ø Searches call stack for a method that can handle (or catch) the exception Call stack Sept 25, 2013 Sprenkle - CSCI Search order for handler Throwable Error Throwable All exceptions indirectly derive from Throwable Ø Child classes: Error and Exception Important Throwable methods Ø getmessage() Detailed message about error Ø printstacktrace() Prints out where problem occurred and path to reach that point Ø getstacktrace() Get the stack in non-text format Exception Sept 25, 2013 Sprenkle - CSCI209 9 Printing Stack Trace Example java.io.filenotfoundexception: fred.txt at java.io.fileinputstream.<init>(fileinputstream.java) at java.io.fileinputstream.<init>(fileinputstream.java) at ExTest.readMyFile(ExTest.java:19) at ExTest.main(ExTest.java:7) How helpful is this output? How user friendly is it? Sept 25, 2013 Sprenkle - CSCI Printing Stack Trace Example java.io.filenotfoundexception: fred.txt at java.io.fileinputstream.<init>(fileinputstream.java) at java.io.fileinputstream.<init>(fileinputstream.java) at ExTest.readMyFile(ExTest.java:19) at ExTest.main(ExTest.java:7) How helpful is this output? How user friendly is it? Useful for debugging your code Generate/display user-friendly errors in finished product Often requires higher-level code to handle exception Sept 25, 2013 Sprenkle - CSCI Exception Classification: Error An internal error Strong convention: reserved for JVM Ø JVM-generated when resource exhaustion or an internal problem Example: Out of Memory error When can that happen in Java? Program s code should not and can not throw an object of this type Unchecked exception Sept 25, 2013 Sprenkle - CSCI

3 Exception Classification: Exception 1.RuntimeException: something that happens because of a programming error Ø Unchecked exception Ø Examples: ArrayOutOfBoundsException, NullPointerException, ClassCastException 2. Checked exceptions Ø A well-written application should anticipate and recover from Compiler enforces Ø Examples: IOException, SQLException Sept 25, 2013 Sprenkle - CSCI Exception Classification Error Unchecked Checked Checked: All non- RuntimeExceptions Throwable IOException Others SQLException Checked Exception Part of java.lang package Unchecked RuntimeException Sept 25, 2013 Sprenkle - CSCI Types of Exceptions Unchecked Any exception that derives from Error or RuntimeException Programmer does not create/handle Try to make sure that they don t occur Often indicates programmer error Ø E.g., precondition violations, not using API correctly Checked Any other exception Programmer creates and handles checked exceptions Compiler-enforced checking Ø Improves reliability* For conditions from which caller can reasonably be expected to recover Sept 25, 2013 Sprenkle - CSCI Types of Unchecked Exceptions 1. Derived from the class Error Ø Any line of code can generate because it is an internal error Ø Don t worry about what to do if this happens 2. Derived from the class RuntimeException Ø Indicates a bug in the program Ø Fix the bug Ø Examples: ArrayOutOfBoundsException, NullPointerException, ClassCastException Sept 25, 2013 Sprenkle - CSCI Checked Exceptions Need to be handled by your program Ø Compiler-enforced Ø Improves reliability* For each method, tell the compiler: Ø What the method returns Ø What could possibly go wrong Advertise the exceptions that a method throws Helps users of your interface know what method does and lets them decide how to handle exceptions Discussion: Why Checked and Unchecked Exceptions? Why do we have exceptions that the compiler doesn t force the programmer to check? Ø Think about examples of unchecked exceptions (ArrayOutOfBoundsException, NullPointerException, ClassCastException) and when those exceptions can occur Sept 25, 2013 Sprenkle - CSCI Sept 25, 2013 Sprenkle - CSCI

4 Methods and Exceptions Example BufferedReader has method readline() Ø Reads a line from a stream, such as a file or network connection Method header: Part of Advertising public String readline() throws IOException THROWING EXCEPTIONS Sept 25, 2013 Sprenkle - CSCI Interpreting the header: readline will Ø return a String (if everything went right) Ø throw an IOException (if something went wrong) Sept 25, 2013 Sprenkle - CSCI Advertising Checked Exceptions Advertising: in Javadoc, document under what conditions each exception is thrown tag Examples of when your method should advertise the checked exceptions that it may throw Ø Your method calls a method that throws a checked exception Ø Your method detects an error in its processing and decides to throw an exception Example: Passing an Exception Up public String readdata(bufferedreader in) throws IOException { String str1; Throws an IOException str1 = in.readline(); return str1; readdata() calls readline(), which can throw an IOException If readline() throws this exception to our method Ø readdata() throws the exception as well Ø Whoever calls readdata will handle exception Sept 25, 2013 Sprenkle - CSCI Sept 25, 2013 Sprenkle - CSCI Throwing An Exception We Created if (month < 1 month > 12) { throw new IllegalArgumentException(); 1. Create a new object of class IllegalArgumentException Ø Class derived from RuntimeException 2. throw it Ø Method ends at this point Ø Calling method handles exception Equivalent in Python? Sept 25, 2013 Sprenkle - CSCI A More Descriptive Exception Four constructors for most Exception classes Ø Default (no parameters) Ø Takes a String message Describe the condition that generated this exception more fully Ø 2 more if (month < 1 month > 12) { throw new IllegalArgumentException( "Month is not in valid range (1-12)"); Best messages include all state that could have contributed to the problem Sept 25, 2013 Sprenkle - CSCI

5 Common Exceptions Name Purpose IllegalArgumentException When caller passes in inappropriate argument IllegalStateException Invocation is illegal because of receiving object s state. (Ex: closing a closed window) Both inherit from RuntimeException May seem like these cover everything but only used for certain kinds of illegal arguments and exceptions Not used when Ø A null argument passed in; should be a NullPointerException Ø Pass in invalid index for an array; should be an IndexOutOfBoundsException Sept 25, 2013 Sprenkle - CSCI Factorial Alternatives public static double factorial( int x ) { if( x < 0 ) return 0.0; double fact = 1.0; while( x > 1 ) { fact *= x; x--; return fact; Sept 25, 2013 Sprenkle - CSCI Factorial Alternatives public static double factorial( int x ) { if( x < 0 ) throw new IllegalArgumentException("x" + "must be >= 0"); double fact = 1.0; while( x > 1 ) { fact *= x; x--; return fact; What are the pros and cons of these approaches? Note, no throws clause in method signature. Why? IllegalArgumentException: Thrown to indicate that a method has been passed an illegal or inappropriate argument Goal: Failure Atomicity After an object throws an exception, the object should be in a well-defined, usable state Ø A failed method invocation should leave object in state prior to invocation Approaches: Ø Check parameters/state before performing operation(s) Ø Do the failure-prone operations first Ø Use recovery code to rollback state Ø Apply to temporary object first, then copy over values Sept 25, 2013 Sprenkle - CSCI Sept 25, 2013 Sprenkle - CSCI Practice Practice public void setbirthday(int month, int day) { public void setbirthday(int month, int day) { How should we implement this method? What are some problems we could face? How should we implement this method? Ø Rule of thumb: Handle error checking first Sept 25, 2013 Sprenkle - CSCI Sept 25, 2013 Sprenkle - CSCI

6 PACKAGES Packages Hierarchical structure of Java classes Ø Directories of directories Use import to access packages Sept 25, 2013 Sprenkle - CSCI Sept 25, 2013 Sprenkle - CSCI java lang net Object String util Date Fully qualified name: java.lang.string Standard Practice To reduce chance of a conflict between names of classes, put classes in packages Use package keyword to say that a class belongs to a package: Ø package java.util; Ø First line in class file Typically, use a unique prefix, similar to domain names Ø com.ibm Ø edu.wlu.cs.logic Sept 25, 2013 Sprenkle - CSCI Importing Packages Can import one class at a time or all the classes within a package Examples: import java.util.date; import java.io.*; Ø * form may increase compile time BUT, no effect on run-time performance Import entire package Sept 25, 2013 Sprenkle - CSCI Javadocs Special comments, which are used to generate HTML documentation Syntax: * Comment */ JAVADOCS Documentation is a love letter that you write to your future self. Damian Conway Put before a class, a method, or a field to describe the respective class/method/field Sept 25, 2013 Sprenkle - CSCI Sept 25, 2013 Sprenkle - CSCI

7 Javadoc Can contain HTML syntax in description Example block tags to describe your <paramname> <description> (include special cases) Ø More that we ll get to later Sept 25, 2013 Sprenkle - CSCI Examples * A simple Java class that models a Chicken. The * state of the chicken is its name, height, and weight * Sara Sprenkle */ Tags always go last in Javadoc comment the height of the chicken, in centimeters */ n the String representing the name of the chicken */ Expect these types of comments on all methods from now on Sept 25, 2013 Sprenkle - CSCI Generating Javadocs From command-line: javadoc [options] [packagenames] [sourcefiles] [@files] Or, using Eclipse Sept 25, 2013 Sprenkle - CSCI Sept 25, 2013 Sprenkle - CSCI Software System Award The Software System Award is given to an institution or individuals recognized for developing software systems that have had a lasting influence, reflected in contributions to concepts and/or commercial acceptance. created by IBM. Eclipse changed the way builders think about tools by defining a set of user interaction paradigms for which domain-specific variants are plugged in and customized for their tool. Conceived to address perceived shortcomings in proprietary software development tools, Eclipse allowed developers to seamlessly integrate their own extensions, specializations, and personalizations. Sept 25, 2013 Sprenkle - CSCI Software System Award It revolutionized the notion of an Integrated Development Environment (IDE) by identifying the conceptual kernel underlying any IDE. Eclipse was designed as an open, extensible platform for application development tools with a Java IDE built on top. In 2004 Eclipse became a not-for-profit corporation. The IBM Eclipse team included John Wiegand, Dave Thomson, Gregory Adams, Philippe Mulet, Julian Jones, John Duimovich, Kevin Haaland, Stephen Northover (now with Oracle), and Erich Gamma (now with Microsoft). Sept 25, 2013 Sprenkle - CSCI

8 Open source integrated development environment (IDE) for Java Has market share for Java IDEs Described as an open extensible IDE for anything and nothing in particular Provides a robust Java development environment Incorporates popular software development tools like JUnit and CVS Ø More on those later this semester Plugins allow extensibility Sept 25, 2013 Sprenkle - CSCI Project/Code Organization workspace directory contains all projects Ø Located in your home directory, unless you specified otherwise Use projects to organize your code Within a project Ø src/ directory contains.java files Ø bin/ directory contains.class files Often hidden in GUI Sept 25, 2013 Sprenkle - CSCI Java Made Easier Creating class s basic functionality Ø See Source and Refactor menus Gives you a list of methods for an object Ø After you type object. Ø Then shows parameters for methods Automatically creates template of Javadoc Ø When you type Autocompletion of variables, methods Formatting code Shows unused fields/variables Shows compiler errors Sept 25, 2013 Sprenkle - CSCI Eclipse Demo Why can Eclipse provide this functionality? (but IDLE can t?) Show Birthday class Ø Override equals and tostring methods Create a new class Ø Generate Main method, Comments Create a String object, see methods used Demonstrate refactoring Ø Rename a field Ø Extract a method (month name) Run the Birthday Class (main) Ø Command line arguments Sept 25, 2013 Sprenkle - CSCI Eclipse Hints After you have written a method, type before the method, and then hit enter and the Javadocs template will be automatically generated for you Use command-spacebar for possible completions Your Eclipse Practice Start up Eclipse Create a new Java project: Assign6 Create a new Java class: Test Ø Checkbox: Main method, comments Ø Add an instance field: private int myvar; Ø Use Source menu to generate a constructor Ø Use Source menu to generate tostring Sept 25, 2013 Sprenkle - CSCI Sept 25, 2013 Sprenkle - CSCI

9 Installing at Home Go to Select Downloads Then Eclipse IDE for Java EE Developers Ø For developing web applications and other enterprise applications Ø Requires Java 6 to run We re using Java 7 for the code we write Ø You ll need to install both Java 6 and 7 Eclipse Discussion Helpful hints Ø Control-spacebar Ø Format the file Ø Auto-templates for Javadocs Sept 25, 2013 Sprenkle - CSCI Sept 25, 2013 Sprenkle - CSCI TODO Assignment 6 Ø Practice using Eclipse Ø Creating abstract class, child classes Ø Responses to questions are important Ø Due Monday not difficult but time-consuming Looking ahead: Exam next Friday Sept 25, 2013 Sprenkle - CSCI

Ø Interface methods are public by default

Ø Interface methods are public by default Objec+ves Interface/Abstract Class Wrap- up Packaging Collec+ons Generics Javadocs Eclipse Sept 30, 2015 Sprenkle - CSCI209 1 Itera+on over Code Assignment 4 à Assignment 5 Demonstrates typical design/implementa+on

More information

Sept 28, 2016 Sprenkle - CSCI Assignment 5 Demonstrates typical design/implementa-on process

Sept 28, 2016 Sprenkle - CSCI Assignment 5 Demonstrates typical design/implementa-on process Objec-ves Packaging Collec-ons Generics Eclipse Sept 28, 2016 Sprenkle - CSCI209 1 Itera-on over Code Assignment 5 Demonstrates typical design/implementa-on process Ø Start with your original code design

More information

Abstract Classes, Exceptions

Abstract Classes, Exceptions CISC 370: Inheritance, Abstract Classes, Exceptions June 15, 1 2006 1 Review Quizzes Grades on CPM Conventions Class names are capitalized Object names/variables are lower case String.doStuff dostuff();

More information

Review: Collec-ons Framework

Review: Collec-ons Framework Objec-ves Collec-ons Ø Maps Traversing Collec-ons Excep-on handling Sept 30, 2016 Sprenkle - CSCI209 1 Review: Collec-ons Framework Interfaces Ø Abstract data types that represent collec-ons Ø Collec-ons

More information

On my Twitter feed: Sept 30, 2016 Sprenkle - CSCI public boolean equals(object o){ if(((birthday) o).getday()!= this.getday()) return false;

On my Twitter feed: Sept 30, 2016 Sprenkle - CSCI public boolean equals(object o){ if(((birthday) o).getday()!= this.getday()) return false; Objec-ves Collec-ons Ø Maps Traversing Excep-ons On my Twitter feed: Rather than teach everyone to code, let's teach them to think. The coding can come later; it's easier. - @rob_pike Sept 30, 2016 Sprenkle

More information

Sept 26, 2016 Sprenkle - CSCI Documentation is a love letter that you write to your future self. Damian Conway

Sept 26, 2016 Sprenkle - CSCI Documentation is a love letter that you write to your future self. Damian Conway Objec,ves Javadocs Inheritance Ø Final methods, fields Abstract Classes Interfaces Sept 26, 2016 Sprenkle - CSCI209 1 JAVADOCS Documentation is a love letter that you write to your future self. Damian

More information

6.Introducing Classes 9. Exceptions

6.Introducing Classes 9. Exceptions 6.Introducing Classes 9. Exceptions Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in Phone: +91-9999-283-283 Learning

More information

16-Dec-10. Consider the following method:

16-Dec-10. Consider the following method: Boaz Kantor Introduction to Computer Science IDC Herzliya Exception is a class. Java comes with many, we can write our own. The Exception objects, along with some Java-specific structures, allow us to

More information

10/7/15. MediaItem tostring Method. Objec,ves. Using booleans in if statements. Review. Javadoc Guidelines

10/7/15. MediaItem tostring Method. Objec,ves. Using booleans in if statements. Review. Javadoc Guidelines Objec,ves Excep,ons Ø Wrap up Files Streams MediaItem tostring Method public String tostring() { String classname = getclass().tostring(); StringBuilder rep = new StringBuilder(classname); return rep.tostring();

More information

Day 8. COMP1006/1406 Summer M. Jason Hinek Carleton University

Day 8. COMP1006/1406 Summer M. Jason Hinek Carleton University Day 8 COMP1006/1406 Summer 2016 M. Jason Hinek Carleton University today s agenda assignments Assignment 4 is out and due on Tuesday Bugs and Exception handling 2 Bugs... often use the word bug when there

More information

Exceptions and Libraries

Exceptions and Libraries Exceptions and Libraries RS 9.3, 6.4 Some slides created by Marty Stepp http://www.cs.washington.edu/143/ Edited by Sarah Heckman 1 Exceptions exception: An object representing an error or unusual condition.

More information

CS 3 Introduction to Software Engineering. 3: Exceptions

CS 3 Introduction to Software Engineering. 3: Exceptions CS 3 Introduction to Software Engineering 3: Exceptions Questions? 2 Objectives Last Time: Procedural Abstraction This Time: Procedural Abstraction II Focus on Exceptions. Starting Next Time: Data Abstraction

More information

Object oriented programming. Instructor: Masoud Asghari Web page: Ch: 7

Object oriented programming. Instructor: Masoud Asghari Web page:   Ch: 7 Object oriented programming Instructor: Masoud Asghari Web page: http://www.masses.ir/lectures/oops2017sut Ch: 7 1 In this slide We follow: https://docs.oracle.com/javase/tutorial/index.html Trail: Essential

More information

BBM 102 Introduction to Programming II Spring Exceptions

BBM 102 Introduction to Programming II Spring Exceptions BBM 102 Introduction to Programming II Spring 2018 Exceptions 1 Today What is an exception? What is exception handling? Keywords of exception handling try catch finally Throwing exceptions throw Custom

More information

Data Structures. 02 Exception Handling

Data Structures. 02 Exception Handling David Drohan Data Structures 02 Exception Handling JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN 0132162709 2012 Pearson Education, Inc., Upper Saddle River, NJ.

More information

Exceptions. CSC207 Winter 2017

Exceptions. CSC207 Winter 2017 Exceptions CSC207 Winter 2017 What are exceptions? In Java, an exception is an object. Exceptions represent exceptional conditions: unusual, strange, disturbing. These conditions deserve exceptional treatment:

More information

Exceptions. References. Exceptions. Exceptional Conditions. CSE 413, Autumn 2005 Programming Languages

Exceptions. References. Exceptions. Exceptional Conditions. CSE 413, Autumn 2005 Programming Languages References Exceptions "Handling Errors with Exceptions", Java tutorial http://java.sun.com/docs/books/tutorial/essential/exceptions/index.html CSE 413, Autumn 2005 Programming Languages http://www.cs.washington.edu/education/courses/413/05au/

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 04: Exception Handling MOUNA KACEM mouna@cs.wisc.edu Fall 2018 Creating Classes 2 Introduction Exception Handling Common Exceptions Exceptions with Methods Assertions and

More information

BBM 102 Introduction to Programming II Spring 2017

BBM 102 Introduction to Programming II Spring 2017 BBM 102 Introduction to Programming II Spring 2017 Exceptions Instructors: Ayça Tarhan, Fuat Akal, Gönenç Ercan, Vahid Garousi Today What is an exception? What is exception handling? Keywords of exception

More information

CSC207H: Software Design. Exceptions. CSC207 Winter 2018

CSC207H: Software Design. Exceptions. CSC207 Winter 2018 Exceptions CSC207 Winter 2018 1 What are exceptions? Exceptions represent exceptional conditions: unusual, strange, disturbing. These conditions deserve exceptional treatment: not the usual go-tothe-next-step,

More information

Exceptions. CSE 142, Summer 2002 Computer Programming 1.

Exceptions. CSE 142, Summer 2002 Computer Programming 1. Exceptions CSE 142, Summer 2002 Computer Programming 1 http://www.cs.washington.edu/education/courses/142/02su/ 12-Aug-2002 cse142-19-exceptions 2002 University of Washington 1 Reading Readings and References»

More information

Exceptions. Readings and References. Exceptions. Exceptional Conditions. Reading. CSE 142, Summer 2002 Computer Programming 1.

Exceptions. Readings and References. Exceptions. Exceptional Conditions. Reading. CSE 142, Summer 2002 Computer Programming 1. Readings and References Exceptions CSE 142, Summer 2002 Computer Programming 1 http://www.cs.washington.edu/education/courses/142/02su/ Reading» Chapter 18, An Introduction to Programming and Object Oriented

More information

EXCEPTION HANDLING. Summer 2018

EXCEPTION HANDLING. Summer 2018 EXCEPTION HANDLING Summer 2018 EXCEPTIONS An exception is an object that represents an error or exceptional event that has occurred. These events are usually errors that occur because the run-time environment

More information

Lecture 20. Java Exceptional Event Handling. Dr. Martin O Connor CA166

Lecture 20. Java Exceptional Event Handling. Dr. Martin O Connor CA166 Lecture 20 Java Exceptional Event Handling Dr. Martin O Connor CA166 www.computing.dcu.ie/~moconnor Topics What is an Exception? Exception Handler Catch or Specify Requirement Three Kinds of Exceptions

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 04: Exception Handling MOUNA KACEM mouna@cs.wisc.edu Spring 2018 Creating Classes 2 Introduction Exception Handling Common Exceptions Exceptions with Methods Assertions

More information

CSE 143 Java. Exceptions 1/25/

CSE 143 Java. Exceptions 1/25/ CSE 143 Java Exceptions 1/25/17 12-1 Verifying Validity of Input Parameters A non-private method should always perform parameter validation as its caller is out of scope of its implementation http://docs.oracle.com/javase/7/docs/technotes/guides/language/assert.html

More information

COMP200 EXCEPTIONS. OOP using Java, based on slides by Shayan Javed

COMP200 EXCEPTIONS. OOP using Java, based on slides by Shayan Javed 1 1 COMP200 EXCEPTIONS OOP using Java, based on slides by Shayan Javed Exception Handling 2 3 Errors Syntax Errors Logic Errors Runtime Errors 4 Syntax Errors Arise because language rules weren t followed.

More information

Exceptions. Examples of code which shows the syntax and all that

Exceptions. Examples of code which shows the syntax and all that Exceptions Examples of code which shows the syntax and all that When a method might cause a checked exception So the main difference between checked and unchecked exceptions was that the compiler forces

More information

Objec-ves JAR FILES. Jar files. Excep-ons. Files Streams. Ø Wrap up Ø Why Excep-ons? 9/30/16. Oct 3, 2016 Sprenkle - CSCI209 1

Objec-ves JAR FILES. Jar files. Excep-ons. Files Streams. Ø Wrap up Ø Why Excep-ons? 9/30/16. Oct 3, 2016 Sprenkle - CSCI209 1 Objec-ves Jar files Excep-ons Ø Wrap up Ø Why Excep-ons? Files Streams Oct 3, 2016 Sprenkle - CSCI209 1 JAR FILES Oct 3, 2016 Sprenkle - CSCI209 2 1 Jar (Java Archive) Files Archives of Java files Package

More information

Assoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Assoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved. Assoc. Prof. Marenglen Biba Exception handling Exception an indication of a problem that occurs during a program s execution. The name exception implies that the problem occurs infrequently. With exception

More information

CSCI Object Oriented Design: Java Review Errors George Blankenship. Java Review - Errors George Blankenship 1

CSCI Object Oriented Design: Java Review Errors George Blankenship. Java Review - Errors George Blankenship 1 CSCI 6234 Object Oriented Design: Java Review Errors George Blankenship Java Review - Errors George Blankenship 1 Errors Exceptions Debugging Java Review Topics Java Review - Errors George Blankenship

More information

CSCI Object-Oriented Design. Java Review Topics. Program Errors. George Blankenship 1. Java Review Errors George Blankenship

CSCI Object-Oriented Design. Java Review Topics. Program Errors. George Blankenship 1. Java Review Errors George Blankenship CSCI 6234 Object Oriented Design: Java Review Errors George Blankenship George Blankenship 1 Errors Exceptions Debugging Java Review Topics George Blankenship 2 Program Errors Types of errors Compile-time

More information

PIC 20A Exceptions. Ernest Ryu UCLA Mathematics. Last edited: November 27, 2017

PIC 20A Exceptions. Ernest Ryu UCLA Mathematics. Last edited: November 27, 2017 PIC 20A Exceptions Ernest Ryu UCLA Mathematics Last edited: November 27, 2017 Introductory example Imagine trying to read from a file. import java.io.*; public class Test { public static void main ( String

More information

To Think About. MyClass.mogrify(new int[] { 1, 2, 4, 6 }));

To Think About. MyClass.mogrify(new int[] { 1, 2, 4, 6 })); A student adds a JUnit test: To Think About @Test public void mogrifytest() { assertequals("mogrify fails", new int[] { 2, 4, 8, 12 }, MyClass.mogrify(new int[] { 1, 2, 4, 6 })); } The test always seems

More information

CS112 Lecture: Exceptions. Objectives: 1. Introduce the concepts of program robustness and reliability 2. Introduce exceptions

CS112 Lecture: Exceptions. Objectives: 1. Introduce the concepts of program robustness and reliability 2. Introduce exceptions CS112 Lecture: Exceptions Objectives: 1. Introduce the concepts of program robustness and reliability 2. Introduce exceptions Materials: 1. Online Java documentation to project 2. ExceptionDemo.java to

More information

CS 61B Data Structures and Programming Methodology. July 7, 2008 David Sun

CS 61B Data Structures and Programming Methodology. July 7, 2008 David Sun CS 61B Data Structures and Programming Methodology July 7, 2008 David Sun Announcements You ve started (or finished) project 1, right? Package Visibility public declarations represent specifications what

More information

Exceptions in Java

Exceptions in Java Exceptions in Java 3-10-2005 Opening Discussion Do you have any questions about the quiz? What did we talk about last class? Do you have any code to show? Do you have any questions about the assignment?

More information

Exception Handling. Sometimes when the computer tries to execute a statement something goes wrong:

Exception Handling. Sometimes when the computer tries to execute a statement something goes wrong: Exception Handling Run-time errors The exception concept Throwing exceptions Handling exceptions Declaring exceptions Creating your own exception Ariel Shamir 1 Run-time Errors Sometimes when the computer

More information

Exceptions and Error Handling

Exceptions and Error Handling Exceptions and Error Handling Michael Brockway January 16, 2015 Some causes of failures Incorrect implementation does not meet the specification. Inappropriate object request invalid index. Inconsistent

More information

Exception Handling. Run-time Errors. Methods Failure. Sometimes when the computer tries to execute a statement something goes wrong:

Exception Handling. Run-time Errors. Methods Failure. Sometimes when the computer tries to execute a statement something goes wrong: Exception Handling Run-time errors The exception concept Throwing exceptions Handling exceptions Declaring exceptions Creating your own exception 22 November 2007 Ariel Shamir 1 Run-time Errors Sometimes

More information

Exception-Handling Overview

Exception-Handling Overview م.عبد الغني أبوجبل Exception Handling No matter how good a programmer you are, you cannot control everything. Things can go wrong. Very wrong. When you write a risky method, you need code to handle the

More information

Reminder. Topics CSE What Are Exceptions?! Lecture 11 Exception Handling

Reminder. Topics CSE What Are Exceptions?! Lecture 11 Exception Handling Reminder CSE 1720 Lecture 11 Exception Handling Midterm Exam" Thursday, Feb 16, 10-11:30" CLH J Curtis Lecture Hall, Room J! will cover all material up to and including Tues Feb 14th! Tues, Feb 7 topic:

More information

CS112 Lecture: Exceptions and Assertions

CS112 Lecture: Exceptions and Assertions Objectives: CS112 Lecture: Exceptions and Assertions 1. Introduce the concepts of program robustness and reliability 2. Introduce exceptions 3. Introduce assertions Materials: 1. Online Java documentation

More information

CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM

CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM Objectives Defining a wellformed method to check class invariants Using assert statements to check preconditions,

More information

Exceptions, try - catch - finally, throws keyword. JAVA Standard Edition

Exceptions, try - catch - finally, throws keyword. JAVA Standard Edition Exceptions, try - catch - finally, throws keyword JAVA Standard Edition Java - Exceptions An exception (or exceptional event) is a problem that arises during the execution of a program. When an Exception

More information

COMP 213. Advanced Object-oriented Programming. Lecture 17. Exceptions

COMP 213. Advanced Object-oriented Programming. Lecture 17. Exceptions COMP 213 Advanced Object-oriented Programming Lecture 17 Exceptions Errors Writing programs is not trivial. Most (large) programs that are written contain errors: in some way, the program doesn t do what

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Version of February 23, 2013 Abstract Handling errors Declaring, creating and handling exceptions

More information

Lecture 19 Programming Exceptions CSE11 Fall 2013

Lecture 19 Programming Exceptions CSE11 Fall 2013 Lecture 19 Programming Exceptions CSE11 Fall 2013 When Things go Wrong We've seen a number of run time errors Array Index out of Bounds e.g., Exception in thread "main" java.lang.arrayindexoutofboundsexception:

More information

CSCI 261 Computer Science II

CSCI 261 Computer Science II CSCI 261 Computer Science II Department of Mathematics and Computer Science Lecture 2 Exception Handling New Topic: Exceptions in Java You should now be familiar with: Advanced object-oriented design -

More information

A problem?... Exceptions. A problem?... A problem?... Suggested Reading: Bruce Eckel, Thinking in Java (Fourth Edition) Error Handling with Exceptions

A problem?... Exceptions. A problem?... A problem?... Suggested Reading: Bruce Eckel, Thinking in Java (Fourth Edition) Error Handling with Exceptions A problem?... Exceptions Suggested Reading: Bruce Eckel, Thinking in Java (Fourth Edition) Error Handling with Exceptions 2 A problem?... A problem?... 3 4 A problem?... A problem?... 5 6 A problem?...

More information

CSC System Development with Java. Exception Handling. Department of Statistics and Computer Science. Budditha Hettige

CSC System Development with Java. Exception Handling. Department of Statistics and Computer Science. Budditha Hettige CSC 308 2.0 System Development with Java Exception Handling Department of Statistics and Computer Science 1 2 Errors Errors can be categorized as several ways; Syntax Errors Logical Errors Runtime Errors

More information

Defensive Programming. Ric Glassey

Defensive Programming. Ric Glassey Defensive Programming Ric Glassey glassey@kth.se Outline Defensive Programming Aim: Develop the programming skills to anticipate problems beyond control that may occur at runtime Responsibility Exception

More information

COS226 - Spring 2018 Class Meeting # 21 April 23, 2018

COS226 - Spring 2018 Class Meeting # 21 April 23, 2018 COS226 - Spring 2018 Class Meeting # 21 April 23, 2018 X Unhandled exception has occurred in your application. if you click continue the application will ignore this error and attempt to continue. If you

More information

EXCEPTION-HANDLING INTRIVIEW QUESTIONS

EXCEPTION-HANDLING INTRIVIEW QUESTIONS EXCEPTION-HANDLING INTRIVIEW QUESTIONS Q1.What is an Exception? Ans.An unwanted, unexpected event that disturbs normal flow of the program is called Exception.Example: FileNotFondException. Q2.What is

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Version of February 23, 2013 Abstract Handling errors Declaring, creating and handling exceptions

More information

Chapter 13 Exception Handling

Chapter 13 Exception Handling Chapter 13 Exception Handling 1 Motivations When a program runs into a runtime error, the program terminates abnormally. How can you handle the runtime error so that the program can continue to run or

More information

Exceptions. Produced by. Introduction to the Java Programming Language. Eamonn de Leastar

Exceptions. Produced by. Introduction to the Java Programming Language. Eamonn de Leastar Exceptions Introduction to the Java Programming Language Produced by Eamonn de Leastar edeleastar@wit.ie Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie

More information

Chapter 8. Exception Handling. CS 180 Sunil Prabhakar Department of Computer Science Purdue University

Chapter 8. Exception Handling. CS 180 Sunil Prabhakar Department of Computer Science Purdue University Chapter 8 Exception Handling CS 180 Sunil Prabhakar Department of Computer Science Purdue University Clarifications Auto cast from char to String does not happen. Cast between int and char happens automatically.

More information

Exception Handling. Chapter 11. Outline. Example: The Quotient app What Are Exceptions? Java By Abstraction Chapter 11

Exception Handling. Chapter 11. Outline. Example: The Quotient app What Are Exceptions? Java By Abstraction Chapter 11 Outline Chapter 11 Exception Handling 11.1 What are Exceptions? 11.1.1 Exception Handling 11.1.2 The Delegation Model 11.2 Java's Exception Constructs 11.2.1 The Basic -catch Construct 11.2.2 Handling

More information

ECE 122. Engineering Problem Solving with Java

ECE 122. Engineering Problem Solving with Java ECE 122 Engineering Problem Solving with Java Lecture 24 Exceptions Overview Problem: Can we detect run-time errors and take corrective action? Try-catch Test for a variety of different program situations

More information

More on Exception Handling

More on Exception Handling Chapter 18 More on Exception Handling Lecture slides for: Java Actually: A Comprehensive Primer in Programming Khalid Azim Mughal, Torill Hamre, Rolf W. Rasmussen Cengage Learning, 2008. ISBN: 978-1-844480-933-2

More information

Writing your own Exceptions. How to extend Exception

Writing your own Exceptions. How to extend Exception Writing your own Exceptions How to extend Exception When would you write your own exception class? When to write your own custom exception is a matter for discussion in your project design team. There

More information

Introduction to Java Written by John Bell for CS 342, Spring 2018

Introduction to Java Written by John Bell for CS 342, Spring 2018 Introduction to Java Written by John Bell for CS 342, Spring 2018 Based on chapters 1 to 6 of Learning Java by Patrick Niemeyer and Daniel Leuck, with additional material from other sources. History I

More information

More on Exception Handling

More on Exception Handling Chapter 18 More on Exception Handling Lecture slides for: Java Actually: A Comprehensive Primer in Programming Khalid Azim Mughal, Torill Hamre, Rolf W. Rasmussen Cengage Learning, 2008. ISBN: 978-1-844480-933-2

More information

17. Handling Runtime Problems

17. Handling Runtime Problems Handling Runtime Problems 17.1 17. Handling Runtime Problems What are exceptions? Using the try structure Creating your own exceptions Methods that throw exceptions SKILLBUILDERS Handling Runtime Problems

More information

Defensive Programming

Defensive Programming Defensive Programming Software Engineering CITS1220 Based on the Java1200 Lecture notes by Gordon Royle Lecture Outline Why program defensively? Encapsulation Access Restrictions Documentation Unchecked

More information

Exceptions and assertions

Exceptions and assertions Exceptions and assertions CSE 331 University of Washington Michael Ernst Failure causes Partial failure is inevitable Goal: prevent complete failure Structure your code to be reliable and understandable

More information

Garbage collec,on Parameter passing in Java. Sept 21, 2016 Sprenkle - CSCI Assignment 2 Review. public Assign2(int par) { onevar = par; }

Garbage collec,on Parameter passing in Java. Sept 21, 2016 Sprenkle - CSCI Assignment 2 Review. public Assign2(int par) { onevar = par; } Objec,ves Inheritance Ø Overriding methods Garbage collec,on Parameter passing in Java Sept 21, 2016 Sprenkle - CSCI209 1 Assignment 2 Review private int onevar; public Assign2(int par) { onevar = par;

More information

Why OO programming? want but aren t. Ø What are its components?

Why OO programming? want but aren t. Ø What are its components? 9/21/15 Objec,ves Assign 1 Discussion Object- oriented programming in Java Java Conven,ons: Ø Constructors Ø Default constructors Ø Sta,c methods, variables Ø Inherited methods Ø Class names: begin with

More information

CS115. Chapter 17 Exception Handling. Prof. Joe X. Zhou Department of Computer Science. To know what is exception and what is exception handling

CS115. Chapter 17 Exception Handling. Prof. Joe X. Zhou Department of Computer Science. To know what is exception and what is exception handling CS115 Pi Principles i of fcomputer Science Chapter 17 Exception Handling Prof. Joe X. Zhou Department of Computer Science CS115 ExceptionHandling.1 Objectives in Exception Handling To know what is exception

More information

More on Objects in JAVA TM

More on Objects in JAVA TM More on Objects in JAVA TM Inheritance : Definition: A subclass is a class that extends another class. A subclass inherits state and behavior from all of its ancestors. The term superclass refers to a

More information

ASSERTIONS AND LOGGING

ASSERTIONS AND LOGGING SUMMARY Exception handling, ASSERTIONS AND LOGGING PROGRAMMAZIONE CONCORRENTE E DISTR. Università degli Studi di Padova Dipartimento di Matematica Corso di Laurea in Informatica, A.A. 2015 2016 rcardin@math.unipd.it

More information

Exceptions vs. Errors Exceptions vs. RuntimeExceptions try...catch...finally throw and throws

Exceptions vs. Errors Exceptions vs. RuntimeExceptions try...catch...finally throw and throws Lecture 14 Summary Exceptions vs. Errors Exceptions vs. RuntimeExceptions try...catch...finally throw and throws 1 By the end of this lecture, you will be able to differentiate between errors, exceptions,

More information

CS 215 Software Design Homework 3 Due: February 28, 11:30 PM

CS 215 Software Design Homework 3 Due: February 28, 11:30 PM CS 215 Software Design Homework 3 Due: February 28, 11:30 PM Objectives Specifying and checking class invariants Writing an abstract class Writing an immutable class Background Polynomials are a common

More information

EXCEPTIONS. Objectives. The try and catch Statements. Define exceptions. Use try, catch and finally statements. Describe exception categories

EXCEPTIONS. Objectives. The try and catch Statements. Define exceptions. Use try, catch and finally statements. Describe exception categories Objectives Define exceptions 8 EXCEPTIONS Use try, catch and finally statements Describe exception categories Identify common exceptions Develop programs to handle your own exceptions 271 272 Exceptions

More information

About This Lecture. Outline. Handling Unusual Situations. Reacting to errors. Exceptions

About This Lecture. Outline. Handling Unusual Situations. Reacting to errors. Exceptions Exceptions Revised 24-Jan-05 CMPUT 115 - Lecture 4 Department of Computing Science University of Alberta About This Lecture In this lecture we will learn how to use Java Exceptions to handle unusual program

More information

Chapter 3 Java Exception

Chapter 3 Java Exception Chapter 3 Java Exception J AVA C O S E @ Q Q. C O M Content A Notion of Exception Java Exceptions Exception Handling User-defined Exceptions How to Use Exception 2 COSE Java Exceptional Condition Divided

More information

CSC207 Winter Section L5101 Paul Gries

CSC207 Winter Section L5101 Paul Gries CSC207 Winter 2017 Section L5101 Paul Gries Software Design An introduction to software design and development concepts, methods, and tools using a statically-typed objectoriented programming language

More information

Sri Vidya College of Engineering & Technology Question Bank

Sri Vidya College of Engineering & Technology Question Bank 1. What is exception? UNIT III EXCEPTION HANDLING AND I/O Part A Question Bank An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program s instructions.

More information

EXCEPTIONS. Java Programming

EXCEPTIONS. Java Programming 8 EXCEPTIONS 271 Objectives Define exceptions Exceptions 8 Use try, catch and finally statements Describe exception categories Identify common exceptions Develop programs to handle your own exceptions

More information

Program Correctness and Efficiency. Chapter 2

Program Correctness and Efficiency. Chapter 2 Program Correctness and Efficiency Chapter 2 Chapter Objectives To understand the differences between the three categories of program errors To understand the effect of an uncaught exception and why you

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Weiss Chapter 1 terminology (parenthesized numbers are page numbers) Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement

More information

Lecture 14 Summary 3/9/2009. By the end of this lecture, you will be able to differentiate between errors, exceptions, and runtime exceptions.

Lecture 14 Summary 3/9/2009. By the end of this lecture, you will be able to differentiate between errors, exceptions, and runtime exceptions. Lecture 14 Summary Exceptions vs. Errors Exceptions vs. RuntimeExceptions...catch...finally throw and throws By the end of this lecture, you will be able to differentiate between errors, exceptions, and

More information

CS Programming Language Java. Fall 2004 Sept. 29

CS Programming Language Java. Fall 2004 Sept. 29 CS3101-3 Programming Language Java Fall 2004 Sept. 29 Road Map today Java review Homework review Exception revisited Containers I/O What is Java A programming language A virtual machine JVM A runtime environment

More information

Exceptions. Errors and Exceptions. Dealing with exceptions. What to do about errors and exceptions

Exceptions. Errors and Exceptions. Dealing with exceptions. What to do about errors and exceptions Errors and Exceptions Exceptions An error is a bug in your program dividing by zero going outside the bounds of an array trying to use a null reference An exception is a problem whose cause is outside

More information

Pages and 68 in [JN] conventions for using exceptions in Java. Chapter 8 in [EJ] guidelines for more effective use of exceptions.

Pages and 68 in [JN] conventions for using exceptions in Java. Chapter 8 in [EJ] guidelines for more effective use of exceptions. CS511, HANDOUT 12, 7 February 2007 Exceptions READING: Chapter 4 in [PDJ] rationale for exceptions in general. Pages 56-63 and 68 in [JN] conventions for using exceptions in Java. Chapter 8 in [EJ] guidelines

More information

CS11 Advanced Java. Winter Lecture 2

CS11 Advanced Java. Winter Lecture 2 CS11 Advanced Java Winter 2011-2012 Lecture 2 Today s Topics n Assertions n Java 1.5 Annotations n Classpaths n Unit Testing! n Lab 2 hints J Assertions! n Assertions are a very useful language feature

More information

Introduction Unit 4: Input, output and exceptions

Introduction Unit 4: Input, output and exceptions Faculty of Computer Science Programming Language 2 Object oriented design using JAVA Dr. Ayman Ezzat Email: ayman@fcih.net Web: www.fcih.net/ayman Introduction Unit 4: Input, output and exceptions 1 1.

More information

CS159. Nathan Sprague

CS159. Nathan Sprague CS159 Nathan Sprague What s wrong with the following code? 1 /* ************************************************** 2 * Return the mean, or -1 if the array has length 0. 3 ***************************************************

More information

Java Exception. Wang Yang

Java Exception. Wang Yang Java Exception Wang Yang wyang@njnet.edu.cn Last Chapter Review A Notion of Exception Java Exceptions Exception Handling How to Use Exception User-defined Exceptions Last Chapter Review Last Chapter Review

More information

CSCI 200 Lab 3 Using and implementing sets

CSCI 200 Lab 3 Using and implementing sets CSCI 200 Lab 3 Using and implementing sets In this lab, you will write a program that manages a set of workers, using the Worker hierarchy you developed in Lab 2. You will also implement your own version

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (IS120) Lecture 30 April 4, 2016 Exceptions hapter 27 HW7: PennPals hat Due: Tuesday Announcements Simplified Example class { public void foo() {.bar(); "here in foo");

More information

Exception Handling. Chapter 11. Java By Abstraction Chapter 11. Outline What Are Exceptions?

Exception Handling. Chapter 11. Java By Abstraction Chapter 11. Outline What Are Exceptions? Chapter 11 Exception Handling Java By Abstraction 11-1 Outline 11.1 What are Exceptions? 11.1.1 Exception Handling 11.1.2 The Delegation Model 11.2 Java's Exception Constructs 11.2.1 The Basic -catch Construct

More information

Exceptions. Produced by. Algorithms. Eamonn de Leastar Department of Computing, Maths & Physics Waterford Institute of Technology

Exceptions. Produced by. Algorithms. Eamonn de Leastar Department of Computing, Maths & Physics Waterford Institute of Technology Exceptions Algorithms Produced by Eamonn de Leastar edeleastar@wit.ie Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie Exceptions ± Definition

More information

Designing Robust Classes

Designing Robust Classes Designing Robust Classes Learning Goals You must be able to:! specify a robust data abstraction! implement a robust class! design robust software! use Java exceptions Specifications and Implementations

More information

CS 112 Programming 2. Lecture 08. Exception Handling & Text I/O (1) Chapter 12 Exception Handling and Text IO

CS 112 Programming 2. Lecture 08. Exception Handling & Text I/O (1) Chapter 12 Exception Handling and Text IO CS 112 Programming 2 Lecture 08 Exception Handling & Text I/O (1) Chapter 12 Exception Handling and Text IO rights reserved. 2 Motivation When a program runs into a runtime error, the program terminates

More information

School of Informatics, University of Edinburgh

School of Informatics, University of Edinburgh CS1Ah Lecture Note 29 Streams and Exceptions We saw back in Lecture Note 9 how to design and implement our own Java classes. An object such as a Student4 object contains related fields such as surname,

More information

A Third Look At Java. Chapter Seventeen Modern Programming Languages, 2nd ed. 1

A Third Look At Java. Chapter Seventeen Modern Programming Languages, 2nd ed. 1 A Third Look At Java Chapter Seventeen Modern Programming Languages, 2nd ed. 1 A Little Demo public class Test { public static void main(string[] args) { int i = Integer.parseInt(args[0]); int j = Integer.parseInt(args[1]);

More information

Objec&ves. Packages Collec&ons Generics. Sept 28, 2016 Sprenkle - CSCI209 1

Objec&ves. Packages Collec&ons Generics. Sept 28, 2016 Sprenkle - CSCI209 1 Objec&ves Packages Collec&ons Generics Sept 28, 2016 Sprenkle - CSCI209 1 PACKAGES Sept 28, 2016 Sprenkle - CSCI209 2 Packages Hierarchical structure of Java classes Ø Directories of directories java lang

More information

Projeto de Software / Programação 3 Tratamento de Exceções. Baldoino Fonseca/Márcio Ribeiro

Projeto de Software / Programação 3 Tratamento de Exceções. Baldoino Fonseca/Márcio Ribeiro Projeto de Software / Programação 3 Tratamento de Exceções Baldoino Fonseca/Márcio Ribeiro baldoino@ic.ufal.br What can go wrong?! result = n1 / n2; In the following slides: 1) Analyze the code; 2) read

More information