SlideShare a Scribd company logo
1 of 15
Download to read offline
Reading Effective 
Java 第3回あなたとJava 
2014.08.08 (Fri) 
@kawakubox
項目57 
例外的状況にだけ例外を使用する
XV]_ 
MRXM! 
[LMPI
XVYI
_ 
QSYRXEMRW?MAGPMQF
a 
!? 
aGEXGL
%VVE]-RHI3YX3JSYRHW)GITXMSRI
_ 
! 
a
あ…ありのまま 今 起こった事を話すぜ! 
! 
おれは配列の要素を走査する処理を書いてくれと頼んだと思ったら、 
try-catchで括られたコードがcomittされてたんだ。 
! 
な…何を言っているのか わからねーと思うが 
おれも 何をされたのか わからなかった…
API設計者へ告ぐ… 
API利用者に通常のフローで例外を強制しないこと。 
! 
Iteratorパターン利用したAPIを例に挙げる 
JSV
-XIVEXSV 'EVHMXI!GEVHWMXIVEXSV
MXILEW2IX
_ 
'EVHGEVH!MXIRIX
a 
next()メソッドは、iteratorの位置に依存している 
➡状態依存メソッド 
hasNext()メソッドは、次の要素の有無を検査する 
➡状態検査メソッド 
! 
状態検査メソッドがないAPIを立付けると、 
例外を捕捉することでしか配列走査処理を実装できなくなる。
項目58 
回復可能な状態にはチェックされる例外を、 
プログラミングエラーには実行時例外を使用する
 Javaにおける例外/エラーの種類 
Exception 
Throwable 
Error 
Runtime 
Exception 
OreOreThrowable 
MyError 
OutOfMemory 
GirlfriendNotExists 
Owata Exception 
Exception 
Error 
API呼び出し側で回復できるような 
状況にはチェックされる例外を適 
用する
 Javaにおける例外/エラーの種類 
Exception 
Throwable 
Error 
Runtime 
Exception 
OreOreThrowable 
MyError 
プログラミングエラーには実行時 
OutOfMemory 
例外を適用する 
GirlfriendNotExists 
Owata Exception 
Exception 
Error 
ex) APIの事前条件エラーなど

More Related Content

Viewers also liked

Master AIRE 2014
Master AIRE 2014Master AIRE 2014
Master AIRE 2014CRI Paris
 
Thompson.Orlandi.Williams.DRAFT presentation
Thompson.Orlandi.Williams.DRAFT presentationThompson.Orlandi.Williams.DRAFT presentation
Thompson.Orlandi.Williams.DRAFT presentationcassye2820
 
01 04 wh_james_dininno
01 04 wh_james_dininno01 04 wh_james_dininno
01 04 wh_james_dininnoJames Dininno
 
Participative tools emerging at the CRI
Participative tools emerging at the CRIParticipative tools emerging at the CRI
Participative tools emerging at the CRICRI Paris
 
Night Science 2012 booklet
Night Science 2012 bookletNight Science 2012 booklet
Night Science 2012 bookletCRI Paris
 
Dsk dunia seni visual thn 3
Dsk dunia seni visual thn 3Dsk dunia seni visual thn 3
Dsk dunia seni visual thn 3Nordin Laguda
 
India Union Budget - 2016
India Union Budget - 2016India Union Budget - 2016
India Union Budget - 2016Sangesh Sase
 

Viewers also liked (8)

Master AIRE 2014
Master AIRE 2014Master AIRE 2014
Master AIRE 2014
 
Biblnk
BiblnkBiblnk
Biblnk
 
Thompson.Orlandi.Williams.DRAFT presentation
Thompson.Orlandi.Williams.DRAFT presentationThompson.Orlandi.Williams.DRAFT presentation
Thompson.Orlandi.Williams.DRAFT presentation
 
01 04 wh_james_dininno
01 04 wh_james_dininno01 04 wh_james_dininno
01 04 wh_james_dininno
 
Participative tools emerging at the CRI
Participative tools emerging at the CRIParticipative tools emerging at the CRI
Participative tools emerging at the CRI
 
Night Science 2012 booklet
Night Science 2012 bookletNight Science 2012 booklet
Night Science 2012 booklet
 
Dsk dunia seni visual thn 3
Dsk dunia seni visual thn 3Dsk dunia seni visual thn 3
Dsk dunia seni visual thn 3
 
India Union Budget - 2016
India Union Budget - 2016India Union Budget - 2016
India Union Budget - 2016
 

Recently uploaded

LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルLoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルCRI Japan, Inc.
 
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)Hiroshi Tomioka
 
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...Toru Tamaki
 
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Gamesatsushi061452
 
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。iPride Co., Ltd.
 
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptxsn679259
 
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。iPride Co., Ltd.
 
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video UnderstandingToru Tamaki
 
Utilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native IntegrationsUtilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native IntegrationsWSO2
 
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半        2024/04/26の勉強会で発表されたものです。新人研修 後半        2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。iPride Co., Ltd.
 
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイスLoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイスCRI Japan, Inc.
 

Recently uploaded (11)

LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルLoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
 
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
 
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
 
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
 
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
 
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
 
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
 
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
 
Utilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native IntegrationsUtilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native Integrations
 
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半        2024/04/26の勉強会で発表されたものです。新人研修 後半        2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。
 
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイスLoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
 

Reading effective java_3rd