IS"死亡是真棒" preferred?真棒、IS、QUOT、preferred

2023-09-02 11:55:50 作者:多处几个男朋友怎么了,我打字快又不是聊不过来!本期小编为您带

最近我参加了杰弗里里希特的有关.NET培训课程。他提到编码死去真棒的一种策略。也就是说,不要写赶上(例外前)甚至在节目或事件循环的根源。如果不处理某些异常抛出,只是让这个过程模具。

Recently I attended Jeffrey Richter's training courses about .NET. He mentions one strategy of coding "Dying is awesome". That is, don't write "catch (Exception ex)" even at the root of program or event loop. If some exception thrown that is not handled, just let the process die.

我不知道这是正确的。就个人而言,我preFER有一个尝试{...}赶上(例外前){登录并尝试恢复} 包裹在顶层执行。事实上,ASP.NET不如有例外情况是遥asXx死亡。如果它死的异常,再一个银弹请求可以沉默的全程服务。

I'm not sure this is right. Personally, I prefer to have a "try {...} catch(Exception ex) {log and try to recover}" to wrap at the top level of execution. Actually, ASP.NET doesn't die if any exception is throw from asXx. If it does die for exception, then one silver-bullet request can silence the whole service.

你怎么看?

推荐答案

我认为这取决于你正在运行什么垂死的后果是什么样的应用程序中。对于许多客户端应用程序,奄奄一息真棒。对于服务器来说,往往没有那么多(和吞和日志为宜)。有没有一个放之四海而皆准的解决办法。

I think it depends on what kind of app you are running and what the consequences of 'dying' are. For many client apps, dying is awesome. For servers, often not so much (and swallow-and-log is appropriate). There's no one-size-fits-all solution.