KEMBAR78
Daftar
Login
Error handle-OOP(รูปแบบและลักษณะการ Error ในโปรแกรม) | PPT
Download free for 30 days
Sign in
Upload
Language (EN)
Support
Business
Mobile
Social Media
Marketing
Technology
Art & Photos
Career
Design
Education
Presentations & Public Speaking
Government & Nonprofit
Healthcare
Internet
Law
Leadership & Management
Automotive
Engineering
Software
Recruiting & HR
Retail
Sales
Services
Science
Small Business & Entrepreneurship
Food
Environment
Economy & Finance
Data & Analytics
Investor Relations
Sports
Spiritual
News & Politics
Travel
Self Improvement
Real Estate
Entertainment & Humor
Health & Medicine
Devices & Hardware
Lifestyle
Change Language
Language
English
Español
Português
Français
Deutsche
Cancel
Save
Submit search
EN
Uploaded by
Anekwong Yoddumnern
PPT, PDF
3,094 views
Error handle-OOP(รูปแบบและลักษณะการ Error ในโปรแกรม)
ความเข้าใจปัญหาการ error ในโปรแกรมและการป้องกันการเกิด error ในลักษณะการดักจับ Error
Education
◦
Read more
0
Save
Share
Embed
Download
Downloaded 19 times
1
/ 26
2
/ 26
3
/ 26
4
/ 26
5
/ 26
6
/ 26
7
/ 26
8
/ 26
9
/ 26
10
/ 26
11
/ 26
12
/ 26
13
/ 26
14
/ 26
15
/ 26
16
/ 26
17
/ 26
18
/ 26
19
/ 26
20
/ 26
21
/ 26
22
/ 26
23
/ 26
24
/ 26
25
/ 26
26
/ 26
More Related Content
PPT
Java Programming [9/12]: Exception Handling
by
IMC Institute
PDF
Java Programming: การจัดการกับข้อผิดพลาด
by
Thanachart Numnonda
PDF
Java Programming: การจัดการกับเหตุการณ์กราฟิก
by
Thanachart Numnonda
PPT
Java Programming [12/12] : Thread
by
IMC Institute
PDF
Java Programming: โครงสร้างควบคุม
by
Thanachart Numnonda
PPTX
Php เงื่อนไขต่างๆ
by
Jaemjan Sriarunrasmee
PDF
บทที่ 11 การดักจับข
by
Theeravaj Tum
PDF
Java Programming: คลาสอินพุตและเอาต์พุต
by
Thanachart Numnonda
Java Programming [9/12]: Exception Handling
by
IMC Institute
Java Programming: การจัดการกับข้อผิดพลาด
by
Thanachart Numnonda
Java Programming: การจัดการกับเหตุการณ์กราฟิก
by
Thanachart Numnonda
Java Programming [12/12] : Thread
by
IMC Institute
Java Programming: โครงสร้างควบคุม
by
Thanachart Numnonda
Php เงื่อนไขต่างๆ
by
Jaemjan Sriarunrasmee
บทที่ 11 การดักจับข
by
Theeravaj Tum
Java Programming: คลาสอินพุตและเอาต์พุต
by
Thanachart Numnonda
What's hot
PDF
Java Programming: อะเรย์และคอลเล็กชั่น
by
Thanachart Numnonda
PDF
Java Programming: การสร้างส่วนต่อประสานกราฟิกกับผู้ใช้ (Java GUI)
by
Thanachart Numnonda
PPTX
โครงสร้างควบคุมการทำงานแบบควบคุมการทำงาน
by
Saim Technology College
PPTX
กลุ่มที่ 6 โปรแกรมย่อยและฟังก์ชันมาตรฐาน
by
Kanchana Theugcharoon
PPTX
ฟังก์ชันในภาษา
by
Sedthawoot Pitapo
PDF
น.ส.ศิริวิภา กาญจนาวิล-59170116-sec-1
by
หน่อย หน่อย
PDF
7 2โครงสร้าง
by
Supaksorn Tatongjai
PDF
Know4 3
by
โรงเรียนอุตรดิตถ์ดรุณี
PDF
59170259 ผลคุณี
by
Beam Suna
PDF
โปรแกรมย่อยและฟังก์ชันมาตรฐาน
by
Prapatsorn Keawnoun
PDF
พื้นฐานภาษาจาวา
by
Sarocha Makranit
PPT
พื้นฐานภาษาจาวา
by
Aeew Autaporn
PPTX
งานนำเสนอ1
by
Pornpimon Aom
PDF
บทที่3คำสั่งควบคุมโปรแกรม
by
pennapa34
PPT
Computer Programming 2.2
by
Saranyu Srisrontong
PPTX
บทที่2
by
tyt13
Java Programming: อะเรย์และคอลเล็กชั่น
by
Thanachart Numnonda
Java Programming: การสร้างส่วนต่อประสานกราฟิกกับผู้ใช้ (Java GUI)
by
Thanachart Numnonda
โครงสร้างควบคุมการทำงานแบบควบคุมการทำงาน
by
Saim Technology College
กลุ่มที่ 6 โปรแกรมย่อยและฟังก์ชันมาตรฐาน
by
Kanchana Theugcharoon
ฟังก์ชันในภาษา
by
Sedthawoot Pitapo
น.ส.ศิริวิภา กาญจนาวิล-59170116-sec-1
by
หน่อย หน่อย
7 2โครงสร้าง
by
Supaksorn Tatongjai
Know4 3
by
โรงเรียนอุตรดิตถ์ดรุณี
59170259 ผลคุณี
by
Beam Suna
โปรแกรมย่อยและฟังก์ชันมาตรฐาน
by
Prapatsorn Keawnoun
พื้นฐานภาษาจาวา
by
Sarocha Makranit
พื้นฐานภาษาจาวา
by
Aeew Autaporn
งานนำเสนอ1
by
Pornpimon Aom
บทที่3คำสั่งควบคุมโปรแกรม
by
pennapa34
Computer Programming 2.2
by
Saranyu Srisrontong
บทที่2
by
tyt13
Viewers also liked
PPTX
Europe
by
Nicolas Quint
PDF
Como informatizar sua empresa
by
Senior Consultoria em Gestão e Marketing
PDF
SPFF 2017 Moncton High School: Menu des activités
by
Martine Paquet
PDF
The Science of Education Part 1 by Caleb Gattegno
by
Educational Solutions
PDF
Trust, but verify | Testing with Docker Containers
by
Nan Liu
PPTX
Barbati Vs Femei
by
Stefan Cristian
PDF
Zorbalık
by
Yanki Yazgan
PPTX
Come creare un blog che funziona in 28 mosse!
by
Alessandro Scuratti
PPTX
What is ICDE about? A global player and......
by
icdeslides
PDF
ENVIRONMENTAL NOISE POLLUTION MONITOR.
by
Madan Krishna
PPTX
Driving Economic Growth through Scale Up® Ecosystems
by
Daniel Isenberg
PPTX
APIを叩くだけでない、Deep Learning on AWS で自分だけの学習モデルを作ろう! by JAWS-UG AI支部
by
Daisuke Nagao
PDF
21 Periscope Tips for Winning Broadcasts
by
Donna Moritz
PPTX
Customer Centred Business Decisions in the Enterprise
by
Jake Causby
PPTX
The Australian Cyber Security Growth Network Strategy and Goals
by
Australian Cyber Security Growth Network Ltd
PPTX
実践研究フォーラムの仕掛け―実践研究を実現するシステムの構築をめざして―
by
憲章 古屋
PPT
Research Methods and Paradigms
by
Dr Bryan Mills
PDF
Making more intelligent bets Amsterdam 29 03 17
by
Future Agenda
PDF
Testes A/B para aumentar as conversões em e-commerces
by
Rafael Damasceno
PDF
Startups & Gamification (LeanCamp Tehran 2016)
by
Alireza Ranjbar SHourabi
Europe
by
Nicolas Quint
Como informatizar sua empresa
by
Senior Consultoria em Gestão e Marketing
SPFF 2017 Moncton High School: Menu des activités
by
Martine Paquet
The Science of Education Part 1 by Caleb Gattegno
by
Educational Solutions
Trust, but verify | Testing with Docker Containers
by
Nan Liu
Barbati Vs Femei
by
Stefan Cristian
Zorbalık
by
Yanki Yazgan
Come creare un blog che funziona in 28 mosse!
by
Alessandro Scuratti
What is ICDE about? A global player and......
by
icdeslides
ENVIRONMENTAL NOISE POLLUTION MONITOR.
by
Madan Krishna
Driving Economic Growth through Scale Up® Ecosystems
by
Daniel Isenberg
APIを叩くだけでない、Deep Learning on AWS で自分だけの学習モデルを作ろう! by JAWS-UG AI支部
by
Daisuke Nagao
21 Periscope Tips for Winning Broadcasts
by
Donna Moritz
Customer Centred Business Decisions in the Enterprise
by
Jake Causby
The Australian Cyber Security Growth Network Strategy and Goals
by
Australian Cyber Security Growth Network Ltd
実践研究フォーラムの仕掛け―実践研究を実現するシステムの構築をめざして―
by
憲章 古屋
Research Methods and Paradigms
by
Dr Bryan Mills
Making more intelligent bets Amsterdam 29 03 17
by
Future Agenda
Testes A/B para aumentar as conversões em e-commerces
by
Rafael Damasceno
Startups & Gamification (LeanCamp Tehran 2016)
by
Alireza Ranjbar SHourabi
Similar to Error handle-OOP(รูปแบบและลักษณะการ Error ในโปรแกรม)
PDF
Creating And Using Exceptions
by
CC Nakhon Pathom Rajabhat University
PDF
Creating And Using Exceptions
by
CC Nakhon Pathom Rajabhat University
PPT
บทที่ 1
by
bpatra
PDF
การตรวจสอบและจัดการกับข้อผิดพลาดใน VB..NET 2005 Express Editor
by
Warawut
PDF
การแก้ปัญหาด้วยกระบวนการเทคโนโลยีสารสนเทศ
by
Meaw Sukee
PDF
ขั้นตอนการทำงานภาษาซี
by
mr.somsak phoolpherm
PPT
Java Programming [2/12] : Overview of Java Programming Language
by
IMC Institute
PDF
PBL2
by
supaporn20146
PDF
02 controlflow php
by
JubNatthawan Phoonson
PPTX
03 โครงสร้างและผังงานโปรแกรม
by
pirapongaru
PDF
พื้นฐานภาษาจาวา
by
JK133
PPT
Problem solution
by
Prae Uraiwan
PPTX
Computer Programming 3
by
Saranyu Srisrontong
PDF
Know3 2
by
โรงเรียนอุตรดิตถ์ดรุณี
PDF
โครงสร้างโปรแกรมภาษาซี
by
เทวัญ ภูพานทอง
PPT
งานนำเสนอ1 คอม
by
nuknook
PDF
งานนำเสนอ1 คอม
by
nuknook
PPTX
บทที่ 6-เงื่อนไข-การตัดสินใจ-การควบคุม
by
View Nudchanad
PDF
งานPbl 2
by
Supasawat Setapun
PDF
งานPblที่2
by
Naynoyjolii
Creating And Using Exceptions
by
CC Nakhon Pathom Rajabhat University
Creating And Using Exceptions
by
CC Nakhon Pathom Rajabhat University
บทที่ 1
by
bpatra
การตรวจสอบและจัดการกับข้อผิดพลาดใน VB..NET 2005 Express Editor
by
Warawut
การแก้ปัญหาด้วยกระบวนการเทคโนโลยีสารสนเทศ
by
Meaw Sukee
ขั้นตอนการทำงานภาษาซี
by
mr.somsak phoolpherm
Java Programming [2/12] : Overview of Java Programming Language
by
IMC Institute
PBL2
by
supaporn20146
02 controlflow php
by
JubNatthawan Phoonson
03 โครงสร้างและผังงานโปรแกรม
by
pirapongaru
พื้นฐานภาษาจาวา
by
JK133
Problem solution
by
Prae Uraiwan
Computer Programming 3
by
Saranyu Srisrontong
Know3 2
by
โรงเรียนอุตรดิตถ์ดรุณี
โครงสร้างโปรแกรมภาษาซี
by
เทวัญ ภูพานทอง
งานนำเสนอ1 คอม
by
nuknook
งานนำเสนอ1 คอม
by
nuknook
บทที่ 6-เงื่อนไข-การตัดสินใจ-การควบคุม
by
View Nudchanad
งานPbl 2
by
Supasawat Setapun
งานPblที่2
by
Naynoyjolii
More from Anekwong Yoddumnern
PPTX
Android room award 2556
by
Anekwong Yoddumnern
PPTX
ADO.NET -database connection
by
Anekwong Yoddumnern
PPTX
Form design by Dreamweaver CS3/CS5
by
Anekwong Yoddumnern
DOCX
Ict oop java
by
Anekwong Yoddumnern
PDF
00course syllabus[c languagee]
by
Anekwong Yoddumnern
DOC
Course syllabus[c languagee]
by
Anekwong Yoddumnern
Android room award 2556
by
Anekwong Yoddumnern
ADO.NET -database connection
by
Anekwong Yoddumnern
Form design by Dreamweaver CS3/CS5
by
Anekwong Yoddumnern
Ict oop java
by
Anekwong Yoddumnern
00course syllabus[c languagee]
by
Anekwong Yoddumnern
Course syllabus[c languagee]
by
Anekwong Yoddumnern
Error handle-OOP(รูปแบบและลักษณะการ Error ในโปรแกรม)
1.
การจัดการความ ผิดพลาด Error Handling @wong::The hard
core idea system 1
2.
วัตถุประสงค์ เพื่อศึกษาประเภทของข้อผิดพลาด เพื่อศึกษาการเกิดและการควบคุมข้อผิดพลาด เพื่อศึกษาการจัดการข้อผิดพลาด 2
3.
ประเภทของข้อผิดพลาด Syntax Error Run-Time Error Logical
Error 3
4.
Syntax Error เป็นการผิดพลายชนิดร้ายแรง เนื่องจากผิดหลัก หรือโครงสร้างของภาษา
(Syntax or Symmetric) ความผิดพลาดประเภทนี้ไม่ สามารถคอมไพล์ได้เลย เช่น การไม่ได้ปดคำาสั่ง ิ ด้วย ; เช่น System.out.Print(“Hello”) 4
5.
Run – Time
Error เป็นความผิดพลาดที่ไม่ร้ายแรง ความผิดพลาด ประเภทนีโปรแกรมสามารถคอมไพล์ได้ แต่ run ้ ไม่ได้ เช่น การหารด้วย 0 หรือการอ้างขอบเขต ของ Array เกินกว่าที่กำาหนดไว้ 1. class TestError { 2. public static void main(String s[]){ 3. System.out.Print(“Hello” +s[0]); 4. } 5. } 5
6.
Logical Error เป็นความผิดพลาดที่ตรวจพบยากมากเนืองจาก ่ โปรแกรมสามารถทำางานได้ตามปกติแต่ผลลัพธ์ ที่ออกนันไม่ตรงกับความเป็นจริง
หรือให้ ้ ผลลัพธ์ที่ไม่สอดคล้องกัน เดือนกุมภาพันธ์ มี 30 วัน เป็นต้น 6
7.
การเกิด Error โดยส่วนมากแล้วการเกิด Error
ในโปรแกรม นั้นสาเหตุใหญ่ คือ การเกิดจากมนุษย์ ไม่ว่าจะ เป็น Error อย่างใดก็ตาม ดังนี้ จุดที่สามารถ ป้องกัน Error เหล่านี้จึงสามารถทำาได้ ตั้งแต่ การวิเคราะห์หรือการทำาความเข้าใจกับระบบ งานเดิม จนกระทั่งถึงการตรวจสอบระบบงาน แต่อย่างไรก็ตามกลไกของภาษาเองก็สามารถ ช่วยในการตรวจสอบความผิดพลาดได้ ตั้งแต่ ในระดับของ Syntax Error และ Run-Time Error โดยอาจแจ้งในรูปของ Error หรือ 7
8.
กลไกการตรวจสอบ ในภาษา assembly จะมีคำาสั่ง
Interrupt ซึ่งมี การทำางานดังนี้ Process to handle interrupt interrupt 8
9.
ปัญหาการนำา Interrupt ไปใช้ในภาษา ระดับสูง ในภาษาระดับสูงบางครั้งการเกิด
Interrupt นั้น ไม่สามารถบอกได้ว่าเกิดขึ้น ณ ที่ใดและเมื่อมี การหยุดการทำางานแล้ว มีการHandle เรียบร้อยแล้ว การกลับมาทำางานบางครั้งไม่ สามารถกลับมาทำางานในตำาแหน่งที่หยุดได้ ภาษระดับสูงที่ใช้ interpreter ก็อาจสามารถใช้ Interrupt ได้ เช่นใน Basic ทั้งนี้เนืองจาก ่ Operation ของภาษาระดับสูงคือประโยค ทั้งนี้ จากการแปลภาษาที่แปลทีละบรรทัดจึงรับรู้ว่า บรรทัดไหนที่มีความผิดพลาดเกิดขึ้น 9
10.
กลไกการตรวจสอบในภาษาขั้นสูง ในภาษาขั้นสูงเองก็มีกลไกการจัดการและการ ตรวจสอบเช่นเดียวกันกับ assembly ซึ่งจะอำานวย ความสะดวกอย่างมากในการเขียนโปรแกรม
เช่น ในภาษา Ada เองก็มี Exception begin <Statements> ซึ่งจะเป็นลักษณะของ Static Exception exception when exception1 = > กล่าวคือ เมื่อโปรแกรม(อยู่ภายใต้ begin – ; <Statements> when exception1 = > end block) ทำางานถึงจุดที่ผิดพลาด ก็จะเรียก ; <Statements> other => ใช้หรือใช้งานการ when Exception ที่ <Statements> ; end; ตรง กับ Exception ที่เกิดขึ้น เมื่อทำางาน เสร็จ แล้วก็จะไปยังคำาสั่ง end เพื่อทำางานต่อ 10
11.
กลไกการตรวจสอบของภาษาจาวา จาวาได้รับเอา Exception Handling
เข้ามา เป็นส่วนหนึ่งของภาษาโดยคอมไพเลอร์จะ ทำาการตรวจสอบการใช้งาน exception handling อย่างเคร่งครัด try่ง{ ซึ ภาษาจาวามีรูป แบบการใช้งาน exception ดังนี้ <statements>;} catch (Throwable1 t) { <statements>;} catch (Throwable2 t) { <statements>;} catch (Throwable3 t) { <statements>;} 11
12.
การทำางาน exception handling จะคล้ายกับ
Ada นั้นคือ ประโยคที่อยู่ใน try block นั้นจะเป็นประโยคที่ทำางานตามปกติ หาก ทำางานจนจบประโยค โดยไม่มีความผิดพลาด เกิดขึ้น ก็จะทำางานที่คำาสั่งหลังประโยค catch block อันสุดท้าย แต่ถ้าหากมี error เกิดขึ้นใน try block โปรแกรมจะหยุดทำางานที่บรรทัดนั้น แล้วสร้าง instance ของ error หรือ exception และ throws ไปยังตำาแหน่งที่มีความผิดพลาดถ้า ประโยคที่มีความผิดพลาดนั้นมี catch block ที่ มีคาพารามิเตอร์ตรงกับ exception ที่เกิดขึ้น ่ ประโยคใน catch block นันก็ถูกทำางาน จาก ้ นั้นโปรแกรมจะทำางานในคำาสั่งหลังประโยค 12
13.
การทำางาน exception handling
หาก exception ที่ถูก throws ออกมาจาก ประโยคใน try block ที่ไม่มี catch block ดัก จับ exception จะถูกส่งออกมาจากเมธอดที่ เกิดความผิดพลาดไปยังเมธอดที่เรียกใช้งาน ซึ่งเรียกว่า exception propagation ถ้า เมธอดที่เรียกใช้นั้นมีการจับ exception นั้น ไปจัดการขบวนการก็สิ้นสุด แต่ถ้าไม่มีก็จะเกิด propagation ไปเรื่อย ๆ จนถ้า exception ออกจาก main แล้วก็จะถูก java interpreter จัดการ ดังนี้ 1. พิมพ์ exception 13 2. พิมพ์ activation stack เพือให้รู้ถึงจุดกำาเนิดและเส้นทาง ่
14.
main() call พิมพ์ exception พิมพ์ activation stack หยุดการทำางาน ของ
JVM Exception Method 1 call Exception Method 2 14
15.
ดำำเนินกำรตำมทีได้ดักจับ ่ Exception main() call Exception Method 1 call Method 2 15
16.
ข้อแตกต่ำงระหว่ำง Interrupt และ Exception Interrupt
นั้นสำมำรถเกิดขึ้นที่เวลำใดก็ได้ บรรทัดใดก็ได้ Exception นั้นเกิดขึ้นกับประโยคบำงประเภท บำงลักษณะเท่ำนั้น ประโยชน์ ทำำให้กำรเขียนนั้นโปรแกรมนั้นง่ำยขึ้น เนื่องจำกมีกำรจำำแนกและคำดกำรณ์ล่วงหน้ำถึง คำำสังที่จะเกิด error ได้ง่ำย ่ 16
17.
ตัวอย่ำง 1. class ArrayOut
{ 2. public static void main(String s []) { 3. System.out.println("Hello " + s[0]); 4. } 5. } Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at ArrayOut.main(ArrayOut.java:3) 17
18.
กำรเพิ่ม exception handling 1.
class ArrayOut { 2. public static void main(String s []) { 3. try 4. { System.out.println("Hello " + s[0]); } 5. catch (ArrayIndexOutOfBoundsException e) 6. { System.out.println("Please try again" + 7. "with command line"); } 8. } 9. } 18
19.
ตัวอย่ำง 1. class TestExcep
{ 2. static void f(){int x = 0; float y = 1/x; } 3. public static void main(String s[]){ 4. try{ 5. f(); 6. }catch (Exception e){ 7. System.out.println("Error divice by 0" + e.getMessage());} 8. } 9. } 19
20.
Throw Statements ใช้สำำหรับกำรโยน exception
ในตำำแหน่งที่ ต้องกำรออกมำออกมำ throw จะตำมด้วย instance ของ exception ที่จะถูกโยน หำก instance นั้นมีอยู่ก่อนก็สำมำรถโยนออกมำได้ เลย แต่ถ้ำไม่มีต้องทำำกำรสร้ำงขึ้นมำด้วยคำำสั่ง new ก่อน คำำสัง throw นั้นอำจอยู่ใน try block ่ ทีมีกำรดักจับ exception หรือไม่ก็อยู่ใน method ที่มีกำรระบุว่ำจะส่ง exception นั้น ออกมำ 20
21.
ตัวอย่ำง 1. class ThrowTest
{ 2. static int div(int x, int y){ 3. try { 4. if (y == 0) 5. throw new Exception(); 6. return x/y; 7. } catch (Exception e){return x/y;} 8. } 9. public static void main(String s[ ]){ 10. System.out.println(div(1,0));} 11.} 21
22.
Method that throws
exception คือการระบุหรือคาดหมายว่า method นั้นจะมี การ throws exception ออกมา โดยเราจะใช้ คำาสัง throws หลังวงเล็บของพารามิเตอร์ตาม ่ ด้วย class ของ exception ที่อาจถูกโยนออก มา 22
23.
ตัวอย่าง 1. class MethodThrows
{ 2. static int div(int x, int y) throws ArithmeticException { 3. return x/y; } 4. public static void main(String s[]){ 5. System.out.println(div(1,0)); 6. } 7. } 23
24.
ตัวอย่าง 1. import java.lang.*
; 2. import java.io.* ; 3. public class Square { 4. public static void main ( String[] a ) throws IOException { 5. BufferedReader stdin = new BufferedReader (new InputStreamReader( System.in) ); 6. String inData; 7. int num ; 8. System.out.println("Enter an integer:"); 9. inData = stdin.readLine(); 10. num = Integer.parseInt( inData ); // convert inData to int 11. System.out.println("The square of " + inData + " is " + num*num ); } } 24
25.
Finally block คือบล็อกที่เป็น option
ว่ามีหรือไม่ก็ได้ ถ้ามีมี ได้เพียง 1 block เป็นบล็อกที่ทำางานเสมอ ไม่ว่า โปรแกรมจะผ่าน try หรือ catch block หรือไม่ try { <statements>; } catch (<parameter>){ <statements>; } finally{ <statements>; } 25
26.
1. class ArrayOut
{ 2. public static void main(String s []) { 3. try 4. { System.out.println("Hello " + s[0]); } 5. catch (ArrayIndexOutOfBoundsException e) 6. { System.out.println("Please try again" + 7. "with command line"); } 8. finally 9. {System.out.println("How are you. ");} 10. } 11. } 26
Download