
第十九章
除錯與測試
Trying hard to speak and
Fighting with my weak hand
Driven to distraction
So part of the plan
When something is broken
And you try to x it
Trying to repair it
Any way you can
I’m diving off the deep end
You become my best friend
I wanna love you
But I don’t know if I can
I know something is broken
And I’m trying to x it
Trying to repair it
Any way I can
Coldplay, “X&Y”
19.0 導論
除錯與測試並不像解偏微分方程式、繪製酷炫圖形或製作複雜互動式介面那麼有成就
感,然而卻十分接近愛迪生精神。通常於 Mathematica 建立程式只花了 10% 的時間,但
卻花了 90% 的時間除錯及測試,Mathematica 的互動式環境鼓勵你以循序漸進方式開發
程式,因此在以程式解決大型問題之前,你會先建立規模較小的問題,並以此測試、調
整程式,在重複此過程數次之後,程式規模逐漸變大,當你覺得終於開發成功了,才用
來解決真正的大型問題。然而輸出結果經常不如你所預期。本章訣竅 19.1 至 19.6 介紹
了 Mathematica 前端介面中各種