Dedian  
          -- 關(guān)注搜索引擎的開發(fā)
          日歷
          <2006年4月>
          2627282930311
          2345678
          9101112131415
          16171819202122
          23242526272829
          30123456
          統(tǒng)計(jì)
          • 隨筆 - 82
          • 文章 - 2
          • 評論 - 228
          • 引用 - 0

          導(dǎo)航

          常用鏈接

          留言簿(8)

          隨筆分類(45)

          隨筆檔案(82)

          文章檔案(2)

          Java Spaces

          搜索

          •  

          積分與排名

          • 積分 - 65579
          • 排名 - 817

          最新評論

          閱讀排行榜

          評論排行榜

           
          purpose:

          Make your code robust and protect your code from invalid data, events or other unexpectable impact.

          good habits:

          -- Handle for invalid inputs (data from external sources, routine input parameters)
          ??? a. garbage in, nothing out
          ??? b. garbage in, error message out
          ??? c. no garbage allowed in

          -- Build your own assert machanism (for debugging purpose)
          ??? a. avoid putting executable code into assertion (otherwise will miss some execution code when releasing)
          ???
          -- Error-Handling Techniques
          ??? a. return a neutral/closest value
          ??? b. skip to next valid data
          ??? c. return last valid data
          ??? d. Log a warning message to a file (Log file)
          ??? e. Return a defined error code (Throw an exception)
          ??? f. call an error-processing routine/object
          ??? g. display an error message (System.out.print)
          ??? h. shut down

          -- tips for Exception mechanism
          ??? a. avoid throwing exceptions in constructors and destrictors unless you catch them in the same place.
          ??? b. throw exceptions at the right level of abstraction
          ??? c. avoid empty catch blocks
          ??? d. consider creating your own project-specific exception class, which can serve as the base class for all exceptions thrown on your project. This supports centralizing and standardizing logging, error reporting and so on.

          -- Damage-containment strategy: Barricade your program (add a firewall layer for your code which maybe contains Assertions and Error-handlers)

          -- Debugging Aids
          ??? a. use offensive programming to notify yourself the potential errors
          ??? b. handle exception cases in a way that makes them obvious during development and recoverable when production code is running.
          ??? c. use version-control tools and build tools like ant and make


          posted on 2006-04-22 05:40 Dedian 閱讀(152) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
           
          Copyright © Dedian Powered by: 博客園 模板提供:滬江博客
          主站蜘蛛池模板: 曲靖市| 临夏市| 蕉岭县| 滦平县| 辰溪县| 长兴县| 探索| 伊宁县| 奉节县| 普安县| 防城港市| 色达县| 吉首市| 绍兴县| 兰州市| 临海市| 望谟县| 仪征市| 吉木萨尔县| 青河县| 都昌县| 乌鲁木齐市| 武城县| 紫阳县| 卢龙县| 松原市| 荔浦县| 兴仁县| 康平县| 通化县| 禹城市| 江安县| 威远县| 开远市| 蒙自县| 邓州市| 霍州市| 特克斯县| 彝良县| 保靖县| 兴隆县|