Not in notes
Vet Clinic Exercise Not in notes What is cheating, again? We - - PowerPoint PPT Presentation
Vet Clinic Exercise Not in notes What is cheating, again? We - - PowerPoint PPT Presentation
Vet Clinic Exercise Not in notes What is cheating, again? We encourage you to talk to fellow students about assignments but you must write your code individually . Good rule of thumb: if you don't take notes during a Not in notes
Not in notes
What is cheating, again?
- We encourage you to talk to fellow students about
assignments but you must write your code individually.
- Good rule of thumb: if you don't take notes during a
discussion about assignments, the code you write is truly your own.
- If you didn't write your code yourself from scratch,
you're cheating.
- The consequences of getting caught are significant and not
worth the risk: grade of 0 for course, reprimand on official transcript, etc...
Not in notes
Unit 10: exception handling and file I/O
Today: broad overview of exceptions and try-catch blocks (don't worry about the details) Friday: More details about exceptions, and we begin File I/O...
Not in notes
Computer Science is...
Data Mining
Extracting patterns from huge amounts of data.
- Statistical analysis
- Data collection and
pre-processing
- Used for marketing, fraud
detection, scientific discovery.
- Privacy concerns!
(Web 2.0 companies are really into data mining.)
Not in notes
Exception in thread "main" java.lang.NullPointerException at VetClinicTest.main(VetClinicTest.java:7) Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2 at VetClinicTest.main(VetClinicTest.java:8)
We have caused lots of exceptions so far in this course
Not in notes
Exceptions can be “thrown” in at least 2 ways
- You do something silly in your code so that
your program crashes
- The user of your program does something
silly so that your program crashes.
- e.g. You ask them to enter an int and they enter a
letter.
Not in notes
There are several ways to deal with exceptions
- Fix your code so that the exception can't
possibly occur anymore
- This is what we have been doing so far.
- Describe what your program should do if an
exception occurs by adding a try/catch block to your code.
Not in notes
Good programming practice: separate error identification from error handling
Suppose m1 is a method that calls another method m2:
- m1 does no try to figure out which errors can possibly
come up due to calling m2.
- Instead, m2 passes on error information its caller, m1.
- The caller, m1, handles any error information that it is
provided with by m2.
- This is why Java has exceptions: exceptions are
automatically passed from a method to its callers.
Not in notes
To do for Friday
Read “official” slides on exceptions and file I/O
- http://www.cs.mcgill.ca/~cs202/2010-
09/lectures/main/unit-10/10--exceptions.pdf
- http://www.cs.mcgill.ca/~cs202/2010-