彻底使用“if”语句或“try / catch”块? [英] Thorough use of 'if' statements or 'try/catch' blocks?
问题描述
给我一些你的想法,这是一个更好的编码实践/使更高效的代码/更漂亮/任何:增加和提高你的使用if语句预测和捕获潜在问题的能力?或者只是一般使用try / catch一般?
Give me some of your thoughts on which is a better coding practice/makes more efficient code/looks prettier/whatever: Increasing and improving your ability to use if statements to anticipate and catch potential problems? Or simply making good use of try/catch in general?
让我们说这是Java(如果重要的话)。
Let's say this is for Java (if it matters).
编辑:我目前正在将自己从一些不可否认的过时和约束的当前编码做法转变,但我有点担心在几个点上这样做的必要性如此)。我只是要求一些观点。
I'm presently transitioning myself away from some admittedly out-dated and constrained current coding practices, but I'm a little torn on the necessity of doing so on a few points (such as this). I'm simply asking for some perspectives on this. Not a debate.
推荐答案
这个辩论(2003)是好的:
this debate (2003) was good:
http://www.joelonsoftware.com/items/2003/10/ 13.html
http://nedbatchelder.com/blog/200310/joel_on_exceptions.html
这篇关于彻底使用“if”语句或“try / catch”块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!