SlideShare a Scribd company logo
Teddy Chen
teddy@teddysoft.tw
   Feb. 21 2013
Copyright@2013 Teddysoft
系統不穩定




        3
4
5
6
Problem




          7
Problem




          8
Copyright@2013 Teddysoft
• Correctness
  – Contract Specification(超出範圍)


• Robustness
  – Exception Handling




                 Copyright@2013 Teddysoft
Copyright@2013 Teddysoft
Checked
Exception
                  Throwable
                                               Unchecked
                                               Exception


             Exception              Error


            RuntimeException


                    Copyright@2013 Teddysoft
declare




handle
         Copyright@2013 Teddysoft
Copyright@2013 Teddysoft
Copyright@2013 Teddysoft
• Checked exceptions for recoverable
      conditions
       – 打死不知道要如何去recover 任何東東?

class FileService {
…                                             backup () {
                                                  FileService fs = new
    public copy (String s)                                      FileService();
             throws IOException {                 try {
       …                                              fs.copy(“a.txt”);
      if (error)                                  }
         throw new                                catch (IOException e){
             IOException(“reason”);               // exception handling code
    }                                           }
}                                             }
                              Copyright@2013 Teddysoft
1




2




3


    Copyright@2013 Teddysoft
1




                           2




                                   3




Copyright@2013 Teddysoft
• 我就是不喜歡checked exception,咬我啊!
• 例如,Standard Widget Toolkit (SWT,
  Eclipse的UI元件)只使用unchecked
  exception:
 – SWTException用來表示可修復的SWT錯誤。
 – SWTError則用來表示不可修復的錯誤。




             Copyright@2013 Teddysoft
Your
application


Spring
                  DataAccessException                  unchecked
Framework



                                                       checked
   Java       SQLException        HibernateException



                  technology-
                   technology-
                  specific
                   specific
                     Copyright@2013 Teddysoft
Copyright@2013 Teddysoft
•   Exception Type
•   Recoverability
•   Application Context
•   Robustness Level
    – G1: Error-reporting (錯誤回報)
    – G2: State-recovery (狀態回復)
    – G3: Behavior-recovery (行為回復)
• Exception Handling Policy
                  Copyright@2013 Teddysoft
Copyright@2013 Teddysoft
Copyright@2013 Teddysoft
練習1: 如果Accepter收到一
                Message



Presentation
Layer
                    E'' 5. report
                                                    個 IOException,鄉民們第
                                                    一個反應是什麼?
                  AppWin


Application         E' 4. wrap
Layer
                 GameServer


Service Layer
                                3. recover
                     E 2. rethrow
                                                    練習2: 如果Accepter收到
                  Acceptor                          一個 RuntimeException,
                                                    鄉民們第一個反應是什麼?
 JVM                  E 1. throw




                                             Copyright@2013 Teddysoft
Message                             練習3: 如果Accepter收到一
Presentation        E'' 5. report
                                                    個 IOException,鄉民們該
Layer
                  AppWin                            如何處置?
Application         E' 4. wrap
Layer
                 GameServer
                                3. recover

Service Layer        E 2. rethrow
                                                    練習4: 如果Accepter收到
                  Acceptor
                                                    一個 RuntimeException,
 JVM                  E 1. throw
                                                    鄉民們該如何處置?

                                             Copyright@2013 Teddysoft
Message                             練習5: 如果Accepter收到一
Presentation        E'' 5. report
                                                    個 IOException,鄉民們該
Layer
                  AppWin                            如何處置?
Application         E' 4. wrap
Layer
                 GameServer
                                3. recover           練習6: 如果GameServer收
Service Layer        E 2. rethrow

                  Acceptor
                                                     到 IOException ,鄉民們該
                                                     如何處置?
 JVM                  E 1. throw




                                             Copyright@2013 Teddysoft
Message



Presentation
Layer
                    E'' 5. report
                                                  練習7: Accepter的RL要
                  AppWin


                    E' 4. wrap
                                                  設為多少?
Application
Layer
                 GameServer
                                3. recover

Service Layer        E 2. rethrow
                                                   練習8: GameServer的RL
                  Acceptor

                                                   要設為多少?
 JVM                  E 1. throw




                                             Copyright@2013 Teddysoft
Message



Presentation
Layer
                    E'' 5. report
                                                    練習9: Acceptor這一層
                  AppWin
                                                    有哪些policy可用?
Application         E' 4. wrap
Layer
                 GameServer
                                3. recover

Service Layer        E 2. rethrow

                  Acceptor                          練習10: GameServer這
 JVM
                                                    一層有哪些policy可用?
                      E 1. throw




                                             Copyright@2013 Teddysoft
Copyright@2013 Teddysoft   30

More Related Content

What's hot

Deep dive into Xtext scoping local and global scopes explained
Deep dive into Xtext scoping local and global scopes explainedDeep dive into Xtext scoping local and global scopes explained
Deep dive into Xtext scoping local and global scopes explained
Holger Schill
 
Real Life Clean Architecture
Real Life Clean ArchitectureReal Life Clean Architecture
Real Life Clean Architecture
Mattia Battiston
 
Introduction to JUnit
Introduction to JUnitIntroduction to JUnit
Introduction to JUnit
Devvrat Shukla
 
Hexagonal architecture for java applications
Hexagonal architecture for java applicationsHexagonal architecture for java applications
Hexagonal architecture for java applications
Fabricio Epaminondas
 
Spring Data JPA from 0-100 in 60 minutes
Spring Data JPA from 0-100 in 60 minutesSpring Data JPA from 0-100 in 60 minutes
Spring Data JPA from 0-100 in 60 minutes
VMware Tanzu
 
Cryptography for Java Developers: Nakov jProfessionals (Jan 2019)
Cryptography for Java Developers: Nakov jProfessionals (Jan 2019)Cryptography for Java Developers: Nakov jProfessionals (Jan 2019)
Cryptography for Java Developers: Nakov jProfessionals (Jan 2019)
Svetlin Nakov
 
Swift Tutorial For Beginners | Swift Programming Tutorial | IOS App Developme...
Swift Tutorial For Beginners | Swift Programming Tutorial | IOS App Developme...Swift Tutorial For Beginners | Swift Programming Tutorial | IOS App Developme...
Swift Tutorial For Beginners | Swift Programming Tutorial | IOS App Developme...
Edureka!
 
Mock your way with Mockito
Mock your way with MockitoMock your way with Mockito
Mock your way with Mockito
Vitaly Polonetsky
 
[Kotlin 讀書會第五梯次] 深入淺出 Kotlin 第一章導讀
[Kotlin 讀書會第五梯次] 深入淺出 Kotlin 第一章導讀[Kotlin 讀書會第五梯次] 深入淺出 Kotlin 第一章導讀
[Kotlin 讀書會第五梯次] 深入淺出 Kotlin 第一章導讀
Shengyou Fan
 
HTML5--The 30,000' View (A fast-paced overview of HTML5)
HTML5--The 30,000' View (A fast-paced overview of HTML5)HTML5--The 30,000' View (A fast-paced overview of HTML5)
HTML5--The 30,000' View (A fast-paced overview of HTML5)
Peter Lubbers
 
Clean Code I - Best Practices
Clean Code I - Best PracticesClean Code I - Best Practices
Clean Code I - Best Practices
Theo Jungeblut
 
Mockito a simple, intuitive mocking framework
Mockito   a simple, intuitive mocking frameworkMockito   a simple, intuitive mocking framework
Mockito a simple, intuitive mocking framework
Phat VU
 
Pentesting iOS Applications
Pentesting iOS ApplicationsPentesting iOS Applications
Pentesting iOS Applications
jasonhaddix
 
Python Deserialization Attacks
Python Deserialization AttacksPython Deserialization Attacks
Python Deserialization Attacks
NSConclave
 
Black Hat EU 2010 - Attacking Java Serialized Communication
Black Hat EU 2010 - Attacking Java Serialized CommunicationBlack Hat EU 2010 - Attacking Java Serialized Communication
Black Hat EU 2010 - Attacking Java Serialized Communication
msaindane
 
An introduction to Google test framework
An introduction to Google test frameworkAn introduction to Google test framework
An introduction to Google test framework
Abner Chih Yi Huang
 
Defending against Java Deserialization Vulnerabilities
 Defending against Java Deserialization Vulnerabilities Defending against Java Deserialization Vulnerabilities
Defending against Java Deserialization Vulnerabilities
Luca Carettoni
 
Java Deserialization Vulnerabilities - The Forgotten Bug Class
Java Deserialization Vulnerabilities - The Forgotten Bug ClassJava Deserialization Vulnerabilities - The Forgotten Bug Class
Java Deserialization Vulnerabilities - The Forgotten Bug Class
CODE WHITE GmbH
 
Clean code
Clean codeClean code
Clean code
Arturo Herrero
 
Web Assembly (on the server)
Web Assembly (on the server)Web Assembly (on the server)
Web Assembly (on the server)
Massimo Ferre'
 

What's hot (20)

Deep dive into Xtext scoping local and global scopes explained
Deep dive into Xtext scoping local and global scopes explainedDeep dive into Xtext scoping local and global scopes explained
Deep dive into Xtext scoping local and global scopes explained
 
Real Life Clean Architecture
Real Life Clean ArchitectureReal Life Clean Architecture
Real Life Clean Architecture
 
Introduction to JUnit
Introduction to JUnitIntroduction to JUnit
Introduction to JUnit
 
Hexagonal architecture for java applications
Hexagonal architecture for java applicationsHexagonal architecture for java applications
Hexagonal architecture for java applications
 
Spring Data JPA from 0-100 in 60 minutes
Spring Data JPA from 0-100 in 60 minutesSpring Data JPA from 0-100 in 60 minutes
Spring Data JPA from 0-100 in 60 minutes
 
Cryptography for Java Developers: Nakov jProfessionals (Jan 2019)
Cryptography for Java Developers: Nakov jProfessionals (Jan 2019)Cryptography for Java Developers: Nakov jProfessionals (Jan 2019)
Cryptography for Java Developers: Nakov jProfessionals (Jan 2019)
 
Swift Tutorial For Beginners | Swift Programming Tutorial | IOS App Developme...
Swift Tutorial For Beginners | Swift Programming Tutorial | IOS App Developme...Swift Tutorial For Beginners | Swift Programming Tutorial | IOS App Developme...
Swift Tutorial For Beginners | Swift Programming Tutorial | IOS App Developme...
 
Mock your way with Mockito
Mock your way with MockitoMock your way with Mockito
Mock your way with Mockito
 
[Kotlin 讀書會第五梯次] 深入淺出 Kotlin 第一章導讀
[Kotlin 讀書會第五梯次] 深入淺出 Kotlin 第一章導讀[Kotlin 讀書會第五梯次] 深入淺出 Kotlin 第一章導讀
[Kotlin 讀書會第五梯次] 深入淺出 Kotlin 第一章導讀
 
HTML5--The 30,000' View (A fast-paced overview of HTML5)
HTML5--The 30,000' View (A fast-paced overview of HTML5)HTML5--The 30,000' View (A fast-paced overview of HTML5)
HTML5--The 30,000' View (A fast-paced overview of HTML5)
 
Clean Code I - Best Practices
Clean Code I - Best PracticesClean Code I - Best Practices
Clean Code I - Best Practices
 
Mockito a simple, intuitive mocking framework
Mockito   a simple, intuitive mocking frameworkMockito   a simple, intuitive mocking framework
Mockito a simple, intuitive mocking framework
 
Pentesting iOS Applications
Pentesting iOS ApplicationsPentesting iOS Applications
Pentesting iOS Applications
 
Python Deserialization Attacks
Python Deserialization AttacksPython Deserialization Attacks
Python Deserialization Attacks
 
Black Hat EU 2010 - Attacking Java Serialized Communication
Black Hat EU 2010 - Attacking Java Serialized CommunicationBlack Hat EU 2010 - Attacking Java Serialized Communication
Black Hat EU 2010 - Attacking Java Serialized Communication
 
An introduction to Google test framework
An introduction to Google test frameworkAn introduction to Google test framework
An introduction to Google test framework
 
Defending against Java Deserialization Vulnerabilities
 Defending against Java Deserialization Vulnerabilities Defending against Java Deserialization Vulnerabilities
Defending against Java Deserialization Vulnerabilities
 
Java Deserialization Vulnerabilities - The Forgotten Bug Class
Java Deserialization Vulnerabilities - The Forgotten Bug ClassJava Deserialization Vulnerabilities - The Forgotten Bug Class
Java Deserialization Vulnerabilities - The Forgotten Bug Class
 
Clean code
Clean codeClean code
Clean code
 
Web Assembly (on the server)
Web Assembly (on the server)Web Assembly (on the server)
Web Assembly (on the server)
 

Viewers also liked

模式入門第一堂課: 30分鐘寫出一個模式
模式入門第一堂課: 30分鐘寫出一個模式模式入門第一堂課: 30分鐘寫出一個模式
模式入門第一堂課: 30分鐘寫出一個模式teddysoft
 
重構三兩事
重構三兩事重構三兩事
重構三兩事
teddysoft
 
Design Patterns這樣學就會了:入門班 Day1 教材
Design Patterns這樣學就會了:入門班 Day1 教材Design Patterns這樣學就會了:入門班 Day1 教材
Design Patterns這樣學就會了:入門班 Day1 教材teddysoft
 
Java 例外處理壞味道與重構技術
Java 例外處理壞味道與重構技術Java 例外處理壞味道與重構技術
Java 例外處理壞味道與重構技術
teddysoft
 
好設計如何好 @ C.C. Agile #14
好設計如何好 @ C.C. Agile #14好設計如何好 @ C.C. Agile #14
好設計如何好 @ C.C. Agile #14
teddysoft
 
那一夜我們說Pattern design patterns 20周年-published
那一夜我們說Pattern design patterns 20周年-published那一夜我們說Pattern design patterns 20周年-published
那一夜我們說Pattern design patterns 20周年-published
teddysoft
 
從五個小故事看敏捷開發精神
從五個小故事看敏捷開發精神從五個小故事看敏捷開發精神
從五個小故事看敏捷開發精神teddysoft
 
了解模式讓你更敏捷 (C C Agile 活動分享)
了解模式讓你更敏捷 (C C Agile 活動分享)了解模式讓你更敏捷 (C C Agile 活動分享)
了解模式讓你更敏捷 (C C Agile 活動分享)
teddysoft
 
[演講] Scrum導入經驗分享
[演講] Scrum導入經驗分享[演講] Scrum導入經驗分享
[演講] Scrum導入經驗分享
teddysoft
 
軟體開發成功的秘訣
軟體開發成功的秘訣軟體開發成功的秘訣
軟體開發成功的秘訣
teddysoft
 
Behavior Driven Development on C.C.Agile
Behavior Driven Development on C.C.AgileBehavior Driven Development on C.C.Agile
Behavior Driven Development on C.C.Agile
Sam Huang
 
7.error management and exception handling
7.error management and exception handling7.error management and exception handling
7.error management and exception handlingDeepak Sharma
 
Kanban in Oracle Applications
Kanban in Oracle ApplicationsKanban in Oracle Applications
Kanban in Oracle Applications
mgarg82
 
Do Languages Matter?
Do Languages Matter?Do Languages Matter?
Do Languages Matter?
Bruce Eckel
 
Seeing system patterns in organizational coaching
Seeing system patterns in organizational coachingSeeing system patterns in organizational coaching
Seeing system patterns in organizational coaching
Jen-Chieh Ko
 
Exception Handling Java
Exception Handling JavaException Handling Java
Exception Handling Java
ankitgarg_er
 
Bdd atdd sbe_tdd_ddd_published
Bdd atdd sbe_tdd_ddd_publishedBdd atdd sbe_tdd_ddd_published
Bdd atdd sbe_tdd_ddd_published
teddysoft
 
HowTo Design your kanban board
HowTo Design your kanban boardHowTo Design your kanban board
HowTo Design your kanban boardJo Seibert
 
Specification by Example
Specification by ExampleSpecification by Example
Specification by Example
Declan Whelan
 
O2 c and p2p cycles
O2 c and p2p cyclesO2 c and p2p cycles
O2 c and p2p cycles
gsriramsunil
 

Viewers also liked (20)

模式入門第一堂課: 30分鐘寫出一個模式
模式入門第一堂課: 30分鐘寫出一個模式模式入門第一堂課: 30分鐘寫出一個模式
模式入門第一堂課: 30分鐘寫出一個模式
 
重構三兩事
重構三兩事重構三兩事
重構三兩事
 
Design Patterns這樣學就會了:入門班 Day1 教材
Design Patterns這樣學就會了:入門班 Day1 教材Design Patterns這樣學就會了:入門班 Day1 教材
Design Patterns這樣學就會了:入門班 Day1 教材
 
Java 例外處理壞味道與重構技術
Java 例外處理壞味道與重構技術Java 例外處理壞味道與重構技術
Java 例外處理壞味道與重構技術
 
好設計如何好 @ C.C. Agile #14
好設計如何好 @ C.C. Agile #14好設計如何好 @ C.C. Agile #14
好設計如何好 @ C.C. Agile #14
 
那一夜我們說Pattern design patterns 20周年-published
那一夜我們說Pattern design patterns 20周年-published那一夜我們說Pattern design patterns 20周年-published
那一夜我們說Pattern design patterns 20周年-published
 
從五個小故事看敏捷開發精神
從五個小故事看敏捷開發精神從五個小故事看敏捷開發精神
從五個小故事看敏捷開發精神
 
了解模式讓你更敏捷 (C C Agile 活動分享)
了解模式讓你更敏捷 (C C Agile 活動分享)了解模式讓你更敏捷 (C C Agile 活動分享)
了解模式讓你更敏捷 (C C Agile 活動分享)
 
[演講] Scrum導入經驗分享
[演講] Scrum導入經驗分享[演講] Scrum導入經驗分享
[演講] Scrum導入經驗分享
 
軟體開發成功的秘訣
軟體開發成功的秘訣軟體開發成功的秘訣
軟體開發成功的秘訣
 
Behavior Driven Development on C.C.Agile
Behavior Driven Development on C.C.AgileBehavior Driven Development on C.C.Agile
Behavior Driven Development on C.C.Agile
 
7.error management and exception handling
7.error management and exception handling7.error management and exception handling
7.error management and exception handling
 
Kanban in Oracle Applications
Kanban in Oracle ApplicationsKanban in Oracle Applications
Kanban in Oracle Applications
 
Do Languages Matter?
Do Languages Matter?Do Languages Matter?
Do Languages Matter?
 
Seeing system patterns in organizational coaching
Seeing system patterns in organizational coachingSeeing system patterns in organizational coaching
Seeing system patterns in organizational coaching
 
Exception Handling Java
Exception Handling JavaException Handling Java
Exception Handling Java
 
Bdd atdd sbe_tdd_ddd_published
Bdd atdd sbe_tdd_ddd_publishedBdd atdd sbe_tdd_ddd_published
Bdd atdd sbe_tdd_ddd_published
 
HowTo Design your kanban board
HowTo Design your kanban boardHowTo Design your kanban board
HowTo Design your kanban board
 
Specification by Example
Specification by ExampleSpecification by Example
Specification by Example
 
O2 c and p2p cycles
O2 c and p2p cyclesO2 c and p2p cycles
O2 c and p2p cycles
 

More from teddysoft

Dci vs aggregate_dddtw_2021-0.3-16-9
Dci vs aggregate_dddtw_2021-0.3-16-9Dci vs aggregate_dddtw_2021-0.3-16-9
Dci vs aggregate_dddtw_2021-0.3-16-9
teddysoft
 
Dci vs aggregate_dddtw_2021-0.3-preview
Dci vs aggregate_dddtw_2021-0.3-previewDci vs aggregate_dddtw_2021-0.3-preview
Dci vs aggregate_dddtw_2021-0.3-preview
teddysoft
 
DDD + Clean Architecture: 從需求到實作
DDD + Clean Architecture: 從需求到實作DDD + Clean Architecture: 從需求到實作
DDD + Clean Architecture: 從需求到實作
teddysoft
 
漫談重構
漫談重構漫談重構
漫談重構
teddysoft
 
Pattern based problem solving-published
Pattern based problem solving-publishedPattern based problem solving-published
Pattern based problem solving-published
teddysoft
 
Agile the timeless way of software development-2019-05-17-v1.2-published
Agile the timeless way of software development-2019-05-17-v1.2-publishedAgile the timeless way of software development-2019-05-17-v1.2-published
Agile the timeless way of software development-2019-05-17-v1.2-published
teddysoft
 
從Bowling Game Kata看敏捷開發
從Bowling Game Kata看敏捷開發從Bowling Game Kata看敏捷開發
從Bowling Game Kata看敏捷開發
teddysoft
 
當Scrum遇到Pattern
當Scrum遇到Pattern當Scrum遇到Pattern
當Scrum遇到Pattern
teddysoft
 
說出一嘴好設計 1.1
說出一嘴好設計 1.1說出一嘴好設計 1.1
說出一嘴好設計 1.1
teddysoft
 
跟著Teddy讀Pattern
跟著Teddy讀Pattern跟著Teddy讀Pattern
跟著Teddy讀Pattern
teddysoft
 
洗白你的軟體架構
洗白你的軟體架構洗白你的軟體架構
洗白你的軟體架構
teddysoft
 
如何學好設計模式
如何學好設計模式如何學好設計模式
如何學好設計模式
teddysoft
 

More from teddysoft (12)

Dci vs aggregate_dddtw_2021-0.3-16-9
Dci vs aggregate_dddtw_2021-0.3-16-9Dci vs aggregate_dddtw_2021-0.3-16-9
Dci vs aggregate_dddtw_2021-0.3-16-9
 
Dci vs aggregate_dddtw_2021-0.3-preview
Dci vs aggregate_dddtw_2021-0.3-previewDci vs aggregate_dddtw_2021-0.3-preview
Dci vs aggregate_dddtw_2021-0.3-preview
 
DDD + Clean Architecture: 從需求到實作
DDD + Clean Architecture: 從需求到實作DDD + Clean Architecture: 從需求到實作
DDD + Clean Architecture: 從需求到實作
 
漫談重構
漫談重構漫談重構
漫談重構
 
Pattern based problem solving-published
Pattern based problem solving-publishedPattern based problem solving-published
Pattern based problem solving-published
 
Agile the timeless way of software development-2019-05-17-v1.2-published
Agile the timeless way of software development-2019-05-17-v1.2-publishedAgile the timeless way of software development-2019-05-17-v1.2-published
Agile the timeless way of software development-2019-05-17-v1.2-published
 
從Bowling Game Kata看敏捷開發
從Bowling Game Kata看敏捷開發從Bowling Game Kata看敏捷開發
從Bowling Game Kata看敏捷開發
 
當Scrum遇到Pattern
當Scrum遇到Pattern當Scrum遇到Pattern
當Scrum遇到Pattern
 
說出一嘴好設計 1.1
說出一嘴好設計 1.1說出一嘴好設計 1.1
說出一嘴好設計 1.1
 
跟著Teddy讀Pattern
跟著Teddy讀Pattern跟著Teddy讀Pattern
跟著Teddy讀Pattern
 
洗白你的軟體架構
洗白你的軟體架構洗白你的軟體架構
洗白你的軟體架構
 
如何學好設計模式
如何學好設計模式如何學好設計模式
如何學好設計模式
 

Recently uploaded

The handout of the design method 20240530
The handout of the design method 20240530The handout of the design method 20240530
The handout of the design method 20240530
Winny Wang
 
一比一原版(Langara毕业证书)兰加拉学院毕业证成绩单如何办理
一比一原版(Langara毕业证书)兰加拉学院毕业证成绩单如何办理一比一原版(Langara毕业证书)兰加拉学院毕业证成绩单如何办理
一比一原版(Langara毕业证书)兰加拉学院毕业证成绩单如何办理
708pb191
 
The handout of service innovation design_20240602
The handout of service innovation design_20240602The handout of service innovation design_20240602
The handout of service innovation design_20240602
Winny Wang
 
The handout of the design method 20240606
The handout of the design method 20240606The handout of the design method 20240606
The handout of the design method 20240606
Winny Wang
 
2024.06.03 唐玄輝 自我介紹 / 國立臺灣科技大學 設計系 教授 / 設計思考與創新研究室 總監
2024.06.03  唐玄輝 自我介紹 / 國立臺灣科技大學 設計系 教授 / 設計思考與創新研究室 總監2024.06.03  唐玄輝 自我介紹 / 國立臺灣科技大學 設計系 教授 / 設計思考與創新研究室 總監
2024.06.03 唐玄輝 自我介紹 / 國立臺灣科技大學 設計系 教授 / 設計思考與創新研究室 總監
NTUST
 
design method and skill course 2024_05_31
design method and skill course 2024_05_31design method and skill course 2024_05_31
design method and skill course 2024_05_31
Winny Wang
 
design method and skill course 2024_05_24
design method and skill course 2024_05_24design method and skill course 2024_05_24
design method and skill course 2024_05_24
Winny Wang
 

Recently uploaded (7)

The handout of the design method 20240530
The handout of the design method 20240530The handout of the design method 20240530
The handout of the design method 20240530
 
一比一原版(Langara毕业证书)兰加拉学院毕业证成绩单如何办理
一比一原版(Langara毕业证书)兰加拉学院毕业证成绩单如何办理一比一原版(Langara毕业证书)兰加拉学院毕业证成绩单如何办理
一比一原版(Langara毕业证书)兰加拉学院毕业证成绩单如何办理
 
The handout of service innovation design_20240602
The handout of service innovation design_20240602The handout of service innovation design_20240602
The handout of service innovation design_20240602
 
The handout of the design method 20240606
The handout of the design method 20240606The handout of the design method 20240606
The handout of the design method 20240606
 
2024.06.03 唐玄輝 自我介紹 / 國立臺灣科技大學 設計系 教授 / 設計思考與創新研究室 總監
2024.06.03  唐玄輝 自我介紹 / 國立臺灣科技大學 設計系 教授 / 設計思考與創新研究室 總監2024.06.03  唐玄輝 自我介紹 / 國立臺灣科技大學 設計系 教授 / 設計思考與創新研究室 總監
2024.06.03 唐玄輝 自我介紹 / 國立臺灣科技大學 設計系 教授 / 設計思考與創新研究室 總監
 
design method and skill course 2024_05_31
design method and skill course 2024_05_31design method and skill course 2024_05_31
design method and skill course 2024_05_31
 
design method and skill course 2024_05_24
design method and skill course 2024_05_24design method and skill course 2024_05_24
design method and skill course 2024_05_24
 

搞懂Java例外處理的難題:Checked與Unchecked Exceptions不再是問題

  • 4. 4
  • 5. 5
  • 6. 6
  • 10. • Correctness – Contract Specification(超出範圍) • Robustness – Exception Handling Copyright@2013 Teddysoft
  • 12. Checked Exception Throwable Unchecked Exception Exception Error RuntimeException Copyright@2013 Teddysoft
  • 13. declare handle Copyright@2013 Teddysoft
  • 16. • Checked exceptions for recoverable conditions – 打死不知道要如何去recover 任何東東? class FileService { … backup () { FileService fs = new public copy (String s) FileService(); throws IOException { try { … fs.copy(“a.txt”); if (error) } throw new catch (IOException e){ IOException(“reason”); // exception handling code } } } } Copyright@2013 Teddysoft
  • 17. 1 2 3 Copyright@2013 Teddysoft
  • 18. 1 2 3 Copyright@2013 Teddysoft
  • 19. • 我就是不喜歡checked exception,咬我啊! • 例如,Standard Widget Toolkit (SWT, Eclipse的UI元件)只使用unchecked exception: – SWTException用來表示可修復的SWT錯誤。 – SWTError則用來表示不可修復的錯誤。 Copyright@2013 Teddysoft
  • 20. Your application Spring DataAccessException unchecked Framework checked Java SQLException HibernateException technology- technology- specific specific Copyright@2013 Teddysoft
  • 22. Exception Type • Recoverability • Application Context • Robustness Level – G1: Error-reporting (錯誤回報) – G2: State-recovery (狀態回復) – G3: Behavior-recovery (行為回復) • Exception Handling Policy Copyright@2013 Teddysoft
  • 25. 練習1: 如果Accepter收到一 Message Presentation Layer E'' 5. report 個 IOException,鄉民們第 一個反應是什麼? AppWin Application E' 4. wrap Layer GameServer Service Layer 3. recover E 2. rethrow 練習2: 如果Accepter收到 Acceptor 一個 RuntimeException, 鄉民們第一個反應是什麼? JVM E 1. throw Copyright@2013 Teddysoft
  • 26. Message 練習3: 如果Accepter收到一 Presentation E'' 5. report 個 IOException,鄉民們該 Layer AppWin 如何處置? Application E' 4. wrap Layer GameServer 3. recover Service Layer E 2. rethrow 練習4: 如果Accepter收到 Acceptor 一個 RuntimeException, JVM E 1. throw 鄉民們該如何處置? Copyright@2013 Teddysoft
  • 27. Message 練習5: 如果Accepter收到一 Presentation E'' 5. report 個 IOException,鄉民們該 Layer AppWin 如何處置? Application E' 4. wrap Layer GameServer 3. recover 練習6: 如果GameServer收 Service Layer E 2. rethrow Acceptor 到 IOException ,鄉民們該 如何處置? JVM E 1. throw Copyright@2013 Teddysoft
  • 28. Message Presentation Layer E'' 5. report 練習7: Accepter的RL要 AppWin E' 4. wrap 設為多少? Application Layer GameServer 3. recover Service Layer E 2. rethrow 練習8: GameServer的RL Acceptor 要設為多少? JVM E 1. throw Copyright@2013 Teddysoft
  • 29. Message Presentation Layer E'' 5. report 練習9: Acceptor這一層 AppWin 有哪些policy可用? Application E' 4. wrap Layer GameServer 3. recover Service Layer E 2. rethrow Acceptor 練習10: GameServer這 JVM 一層有哪些policy可用? E 1. throw Copyright@2013 Teddysoft