程式fatal error致命nonfatal非致命錯誤觀念

請各位前輩指導一下,

我在一本書上有看到這樣的問題,

「為什麼我們會比較希望遇到致命的錯誤,而不是非致命的錯誤」

就書本上的理論是這樣的,

致命的錯誤 :

例如將變數除以零,程式會因為錯誤而停止運作。

非致命的錯誤 :

如應將浮點運算,而只用整數運算,程式所出現的將會是非預期的答案。

所以,在下是這樣想的,

因為致命的錯誤在測試期間,可以容易的找出原因,如果是非致命的錯誤,將會需要更多時間再檢查程式碼上。

因此書本的意思是告訴我,

在建構程式時,應該考慮到會遇到的錯誤類型?

還是只是純粹告訴我兩種的差別。

<或者各位先進有什麼看法>

Update:

補充一下,這是學習C程式設計遇到的問題,想來想去,還是跟各位探討一下...為了釐清觀念,感謝

3 Answers

Rating
  • 1 decade ago
    Favorite Answer

    Programming errors? System faults? Both considerations are integral part of system quality, thus should be considered together.

    I will reply when I have time in a few days.

    2009-11-22 07:51:40 補充:

    First, allow me to make some observations on errors/faults:

    (1) regardless what disciplines, SW programming included, you want to talk

    about, error/fault are and will be part of our lives. Taking computer design for example, all HW

    will eventually fail (an analogy to this is all men will die).

    (2) In addition to understand how an error/fault occurs, we

    also need to consider these parameters:

    (2a) error/fault detection & reporting

    (2b) isolation & fault mitigation

    (2c) recovery

    (2d) correction

    In computation arena, what this means to us is error and

    fault will have to be built in to our computation models.

    (3) now, come back to your question about 致命的錯誤 or non-致命的錯誤: If you apply the model in (2) to them, the

    only difference between them are at (2a) and (2b). For

    (2a) For sure, the fatal ones are not detected and reported

    by the responsible SW; but not sure

    about the non-fatal ones.

    (2b) both errors/faults are not mitigated by the SW and

    allow the OS to kill the SW (fatal error)

    (2c) no recovery for both

    (2d) no correction for both

    (4) What are the consequences of the errors? Who cares about

    the error or the fault? There is a

    western saying – does it matter if there is a giant tree falling down in Siberia but no one is there to see it? Do you prefer to having a dead watch (crashed

    due to timing error) or a running one with +/- 1 minute per day error?

    2009-11-22 07:52:44 補充:

    To me, a non-fatal error might be as bad as fatal ones. One always can find an extremely bad case for either that is worse than the other. (Is this the same as the fighting between republicans and democrats!)

    2009-11-22 07:53:26 補充:

    However, one definitely indication with all fatal fault is that

    (4a) that fault is not well understood, thus, not handled by the SW itself, so that OS kills it.

    (5) So, I think the more important issues are:

    (5a) What error/fault should be taken into consideration of our computation model?

    2009-11-22 07:53:37 補充:

    (5b) How will we do (2a), (2b), (2c), and (2d) for each of them?

    Once the behaviors of errors/faults are understood and under control, death (or re-start) of a process (aka fatal) is indeed a legit fault isolation and mitigation choice.

  • 1 decade ago

    thank you prisoner26535 .

    I will wait for your comments.

  • jian
    Lv 7
    1 decade ago

    所有程式設計者都會遇上幾種錯誤

    1. 語法錯誤 : 通常是指令的語法錯誤, 這個容易解決, 查書或問人就可以解決.

    2. 語意錯誤 : 就是用錯一兩個指令或用錯變數, 解這個問題通常要設中斷點, 看變數實際的值就可以解決.

    3. 邏輯錯誤 : 可能是整個演算式錯誤, 可能變成雞同鴨講, 這就要在錯誤中找到正確的邏輯

    4. 寫不出來 : 這就要高手高高手來提示了

Still have questions? Get your answers by asking now.