Building ASP.NET application - Best Practices

前端 未结 7 710
轻奢々
轻奢々 2020-12-22 18:40

We are building an ASP.NET application and would like to follow the best practices. Some of the best practices are:


Server side Code:

  • Use catch
7条回答
  •  无人及你
    2020-12-22 18:54

    I don't think try/catch blocks are always appropriate for low-level methods. You want to catch (and log/alert, even better!) any errors before they get to the user, of course. But it is often better for a low-level method to just lets its errors get raised up to a higher level. The problem I have seen with low-level error trapping is that it often lets a larger operation continue, but then a result that is not quite correct gets presented to the user or saved to the database, and in the long run it's much more difficult to fix. It's also just a lot of extra clutter in your code to put a try/catch at every level if you're not going to "do anything" with the error until it's raised up to a higher level.

提交回复
热议问题