昨天談到 The Psychology of Everyday Things (p. 131)提到的四點 Designing for Error 作法:
- Understand the causes of error and design to minimize those causes.
- Make it possible to reverse actions- to "undo" then - or make it harder to do what cannot be reversed.
如果有些操作和人生一樣是無法 undo 那該怎麼辦?例如,鄉民們使用網路 ATM『轉帳』,網路 ATM 軟體人總不可能提供 undo 功能,讓鄉民們們在『不小時把錢轉給詐騙集團時』可按下 undo 按鈕吧。雖然這個功能聽起來很不錯,不過『轉帳』是不可逆也不可以 undo 的,而且不小心轉錯會『很傷』,因此,當使用者執行這類的功能時,軟體都會『再三提醒』,這也是這個作法第二部份所說的 make it harder to do what cannot be reversed。
- Make it easier to discover the errors that do occur, and make them easier to correct.
再舉個軟體的例子,假設鄉民們正使用 Eclipse 用 Java 在寫程式。大家都知道,『寫程式是一件超級容易犯錯的工作』,Eclipse 的設計者如何幫助使用者(就是你)來 discover the errors 而且 make them easier to correct?人家想出了 quick fix 這個超讚的功能。以下圖的程式範例為例,Eclipse 偵測到一個語法錯誤(main method 遇到一個 checked exception 但是沒有 catch 或是 declare 這個 checked exception),在錯誤發生的那一行的左邊顯示了一個小X icon 稱之為 marker(以上是 easier to discover)。接下來是 easier to correct 的作法,當使用者按下這個小X icon 之後,Eclipse 顯示建議修改方案(resolution),使用者點選合適的修改方案 Eclipse 便自動幫忙修復這個錯誤。
當年 Teddy 曾經研究過 Eclipse 的 quick fix 機制,大體上就是:
- 利用 visitor 去拜訪 Eclipse JDT (Java Development Tools)所建立的 AST (Abstract Syntax Tree)。Error detection 的邏輯就是寫在 visitor 裡面,plug-in 的開發者可以自行擴充新的 visitor 以便加入自己的錯誤檢查邏輯。
- 當發現錯誤時,產生一個
麵包屑marker 用以標示錯誤發生的『位置』(程式行號)。 - 針對不同種類的 marker,plug-in 開發者提供自定的 resolution(解決方案)以協助使用者排除錯誤。由於 marker 是 plug-in 開發者依據『自訂檢查錯誤邏輯』所產生的一個『錯誤標記』,因此如果此錯誤『存在可能的解決方案』的話,plug-in 開發者自然可以事先提供 resolution 來協助使用者排除問題。當然,有時後這些 resolution 並不一定合用,需要使用者自己動手修改。
- Change the attitude toward errors. Think of an object's user as attempting to do a task, getting there by imperfect approximations. Don't think of the users as making errors; think of the actions as approximations of what is desired.
When someone makes an error, there usually is good reason for it. If it was a mistake, the information available was probably incomplete or misleading. The decision was probably sensible at the time. If it was a slip, it was probably due to poor design or distraction. Errors are usually understandable and logical, once you think through their causes. Don't punish the person for making errors. Don't take offense. But most of all, don't ignore it. Try to design the system to allow for errors. Realize that normal behavior isn't always accurate. Design so that errors are easy to discover and corrections are possible.
以上四點以及上面這一段文字念個幾十次對於 designing for error 就會慢慢有 fu 了...
***
友藏內心獨白:好久沒翻這本書了,都快忘了這本書寫得有多好。