Thorough use of 'if' statements or 'try/catch' blocks?

前端 未结 9 1986
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-12 03:14

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 statem

9条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-12 04:08

    My 2p: Using try/catch is best:

    • it makes it absolutely clear to other coders that you are doing exception handling
    • the compiler understands what you are doing and can perform more appropriate compile-time checks for you

    In my experience, using if-conditional-logic makes it more difficult to distinguish error handling from business logic.

提交回复
热议问题