Что такое findslide.org?

FindSlide.org - это сайт презентаций, докладов, шаблонов в формате PowerPoint.


Для правообладателей

Обратная связь

Email: Нажмите что бы посмотреть 

Яндекс.Метрика

Презентация на тему Exceptions and testing

Problems (errors) vs Exceptions“Problem” – situation when your program behaves not in expected way2 + 2 = 52 + 2 = 4 … but takes 20 seconds to calculate1 / 0 … 1.0 / 0.0File.open(“???123321\5431`”);a =
Exceptions and testing 10/08/2016 Problems (errors) vs Exceptions“Problem” – situation when your program behaves not in Exception nature Java Exception hierarchy  	  Object		 			| 	  	 Throwable Java Exception paradigmClassificationsCompilation errors vs. runtime exceptionsErrors vs ExceptionErrors are either compilation Java compile-time errors Java compile-time errors Java runtime-time exceptionsUnchecked exceptionChecked exceptionCheckTry blockCatch blocksFinally block Try – catch – finally Try – catch – finally: special cases Checked ExceptionWhat is Checked Exception in Java Programming language? In simple language: Unchecked ExceptionUnchecked Exception in Java is those Exceptions whose handling is NOT Unit testingUnit testing – an approach in programming, that allows to check Multiple exception handling Rethrowing exceptions Rethrowing exceptions Task 1Implement your own exception class to handle equation solving problems. Task 2Take your first hometask, problem “Add 2 numbers”. Brush up Task 3For yesterday’s implementation of the Circle Equation add exceptions. Find Extra TaskImplement simple Miner game with console interface.Randomly set up bombsHandle Home TaskWrite the program, that calculated intersection point (class Point) of
Слайды презентации

Слайд 2 Problems (errors) vs Exceptions
“Problem” – situation when your

Problems (errors) vs Exceptions“Problem” – situation when your program behaves not

program behaves not in expected way
2 + 2 =

5
2 + 2 = 4 … but takes 20 seconds to calculate
1 / 0 … 1.0 / 0.0
File.open(“???123321\5431`”);
a = null; a.equals(b);
Exception – problem, that can be detected as something “not expected to happen” (“exceptional”) and handled in your code. In Java language exceptions are implemented as specific kind of objects and operators to handle them.

Слайд 3 Exception nature

Exception nature

Слайд 4 Java Exception hierarchy
Object
|

Java Exception hierarchy 	 Object		 			| 	 	 Throwable


Throwable
/

\
Error Exception
|
RuntimeException

Слайд 5 Java Exception paradigm
Classifications
Compilation errors vs. runtime exceptions

Errors vs

Java Exception paradigmClassificationsCompilation errors vs. runtime exceptionsErrors vs ExceptionErrors are either

Exception
Errors are either compilation errors or serious problems that

should not be handled

Checked (“predictable”) vs Unchecked exceptions
All Errors are Unchecked exceptions


Слайд 6 Java compile-time errors

Java compile-time errors

Слайд 7 Java compile-time errors

Java compile-time errors

Слайд 8 Java runtime-time exceptions
Unchecked exception
Checked exception
Check
Try block
Catch blocks
Finally block

Java runtime-time exceptionsUnchecked exceptionChecked exceptionCheckTry blockCatch blocksFinally block

Слайд 9 Try – catch – finally

Try – catch – finally

Слайд 10 Try – catch – finally: special cases

Try – catch – finally: special cases

Слайд 11 Checked Exception
What is Checked Exception in Java Programming

Checked ExceptionWhat is Checked Exception in Java Programming language? In simple

language? In simple language: Exception which are checked at

Compile time called Checked Exception. Some these are mentioned below. If in your code if some of method throws a checked exception, then the method must either handle the exception or it must specify the exception using throws keyword.

IOException
SQLException
DataAccessException
ClassNotFoundException
InvocationTargetException
MalformedURLException


Слайд 12 Unchecked Exception
Unchecked Exception in Java is those Exceptions

Unchecked ExceptionUnchecked Exception in Java is those Exceptions whose handling is

whose handling is NOT verified during Compile time. These

exceptions occurs because of bad programming. The program won’t give a compilation error. All Unchecked exceptions are direct sub classes of RuntimeException class.

NullPointerException
ArrayIndexOutOfBound
IllegalArgumentException
IllegalStateException


Слайд 13 Unit testing
Unit testing – an approach in programming,

Unit testingUnit testing – an approach in programming, that allows to

that allows to check if parts (units) of your

program behaves right in automatic way
There are few frameworks to implement Unit test. JUnit is pre-installed for Eclipse.

Слайд 14 Multiple exception handling

Multiple exception handling

Слайд 15 Rethrowing exceptions

Rethrowing exceptions

Слайд 16 Rethrowing exceptions

Rethrowing exceptions

Слайд 17 Task 1
Implement your own exception class to

Task 1Implement your own exception class to handle equation solving

handle equation solving problems. Write methods for solutions for:



Linear
Square

Each equation type is a class. Sometimes equations do not have real roots - in this case throw your exception and handle using try-catch-finally it.

Слайд 18 Task 2
Take your first hometask, problem “Add

Task 2Take your first hometask, problem “Add 2 numbers”. Brush

2 numbers”. Brush up the code, handle exceptions correctly

and provide proper reactions (print) on situations:

file not found
other file issues
parsing numbers
arithmetic overflow

Слайд 19 Task 3
For yesterday’s implementation of the Circle

Task 3For yesterday’s implementation of the Circle Equation add exceptions.

Equation add exceptions. Find best existing exception implementations for

these cases.

Слайд 20 Extra Task
Implement simple Miner game with console

Extra TaskImplement simple Miner game with console interface.Randomly set up

interface.
Randomly set up bombs
Handle bomb blast as exception.
Move

is made by typing coordinates (D4)
Handle incorrect inputs
Handle input for already processed cells

A B C D E F G H
1████████████████
2████████████████
3██████ √████████
4████████ √▒▒ √██
5████████▒▒ 4▒▒██
6████████▒▒ √ √██
7████████████████
8████████████████


  • Имя файла: exceptions-and-testing.pptx
  • Количество просмотров: 114
  • Количество скачиваний: 0