如何利用 user 幫你抓 bug
用 try catch 就可以
第12回 AS 讀書會
郭佳甯 / ETREX / 卡卡米
今天的內容
講完了~下課~
今天的內容
Bug
Bug
編譯時期的語法錯誤
你的 compiler 會告訴你
var i:String = 1;
編譯不給你過
Error: Implicit coercion of a value of type int to an unrelated type String.
執行時期的語法錯誤
你的 user 不會告訴你
new Sprite().addChild(null);
他會告訴別人
flash player 崩潰
◢▇▆▅▄▃▂崩╰(〒皿〒)╯潰▂▃▄▅▆▇◣
語意錯誤
我想要一個簡單的排序功能
這樣寫可以嗎?
功
能
程
式
測
試
程
式
這不可能阿 !?
setDepth(container,
displayArray,
depthArray);
if (isCorrectDepth(container,
displayArray,
depthArray) == false)
trace("這不可能阿 !?");
Live Demo
一個一個看
自動化測試 - AsUnit
避免程式設計師已知的語意錯誤
Try Catch
Try Catch
如果我想用 try catch 包住整隻程式
那我至少要寫幾個 try catch ?
很多很多個
Try Catch
Try Catch 基礎教學
Try Catch 執行順序
基本 Try Catch
1 2 4 5 6
巢狀 Try Catch
1 2 3 5 6 7 9 10
Try Catch 執行順序
Try Catch 覆蓋範圍
建構式
歡樂3選1
執行ConstructorTest.runTest會看到?
建構式
事件監聽
歡樂3選1
執行程式後會 trace 出什麼?
事件監聽
try catch 加在 addEventListener 沒用
要加在 handler 身上才行
靜態變數
歡樂3選1
下列敘述何者為真?
靜態變數
Debug 資訊
Debug 資訊
JS
Flash
Error
沒用沒用沒用沒用
其他
郭佳甯 / ETREX / 卡卡米