Download presentation
Presentation is loading. Please wait.
Published byVictor Joseph Modified over 9 years ago
1
Fundamentals of Software Development 1Slide 1 Exceptions What are they?What are they? Why are they useful?Why are they useful? What else can happen at runtime…?What else can happen at runtime…? Wouldn’t it be wonderful? Or would it? From website http://www.dribbleglass.co m/subpages/strange/exce ptions.htm http://www.dribbleglass.co m/subpages/strange/exce ptions.htm
2
Fundamentals of Software Development 1Slide 2 What are they? The program seems to be running along just fine, minding its own business and all, when suddenly…The program seems to be running along just fine, minding its own business and all, when suddenly… Exception in thread "AWT-EventQueue-0" java.lang.ArithmeticException: / by zero at EyeBall.look(EyeBall.java:47) at EyeBall.look(EyeBall.java:47) at Eye.look(Eye.java:78) at Eye.look(Eye.java:78) at Eye.mouseMoved(Eye.java:56) at Eye.mouseMoved(Eye.java:56) at java.awt.AWTEventMulticaster.mouseMoved(AWTEventMulticaster.java:271) at java.awt.AWTEventMulticaster.mouseMoved(AWTEventMulticaster.java:271) at java.awt.Component.processMouseMotionEvent(Component.java:5533) at java.awt.Component.processMouseMotionEvent(Component.java:5533) at java.awt.Component.processEvent(Component.java:5257) at java.awt.Component.processEvent(Component.java:5257) at java.awt.Container.processEvent(Container.java:1966) at java.awt.Container.processEvent(Container.java:1966) at java.awt.Window.processEvent(Window.java:1153) at java.awt.Window.processEvent(Window.java:1153) at java.awt.Component.dispatchEventImpl(Component.java:3955) at java.awt.Component.dispatchEventImpl(Component.java:3955) at java.awt.Container.dispatchEventImpl(Container.java:2024) at java.awt.Container.dispatchEventImpl(Container.java:2024) at java.awt.Window.dispatchEventImpl(Window.java:1766) at java.awt.Window.dispatchEventImpl(Window.java:1766) at java.awt.Component.dispatchEvent(Component.java:3803) at java.awt.Component.dispatchEvent(Component.java:3803) at java.awt.EventQueue.dispatchEvent(EventQueue.java:463) at java.awt.EventQueue.dispatchEvent(EventQueue.java:463) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149) at java.awt.EventDispatchThread.run(EventDispatchThread.java:110) at java.awt.EventDispatchThread.run(EventDispatchThread.java:110) Good grief! What’s all this mean?
3
Fundamentals of Software Development 1Slide 3 What are they? – Run-time errors! Java detects a problem in executing the code.Java detects a problem in executing the code. Java “throws an exception.”Java “throws an exception.” If you don’t “catch” the exception, the program stops and…If you don’t “catch” the exception, the program stops and… Displays “where it was” at many levels – the “dump” you see like when JavaEyes divided by zero.Displays “where it was” at many levels – the “dump” you see like when JavaEyes divided by zero. Start at the top, looking at the dump’s info!
4
Fundamentals of Software Development 1Slide 4 Why are they useful? Exceptions tell us about serious problems running the program, which Java can’t deal with.Exceptions tell us about serious problems running the program, which Java can’t deal with. We then have a chance to fix those…We then have a chance to fix those… Would we be better off if Java hadn’t told us? Generic exception code: try { … } catch (…)
5
Fundamentals of Software Development 1Slide 5 What else can happen…? Exceptions are not the only run-time error…Exceptions are not the only run-time error… There are plenty of “runtime” errors you have to spot yourself.There are plenty of “runtime” errors you have to spot yourself. –For example… I wanted three eyeballs, not two! That button was supposed to say “Exit”, not “Quit”! Why isn’t the red square moving?
6
Fundamentals of Software Development 1Slide 6 And of course… Hey – DoublePedant is producing the wrong output!Hey – DoublePedant is producing the wrong output! Rule 1 of software development is: Everything the program is supposed to do must be tested or… It doesn’t work!!!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.