次の方法で共有


Windows Azure Guidance – Failure recovery – Part III (Small tweak, great benefits)

In the previous post, my question was about a small change in the code that would yield a big improvement. The answer is:

 image

What changed?

  1. No try / catch
  2. We reversed the order of writes: first we write the details, then we write the “header” or “master” record for the expense.

If the last SaveChanges fails, then there will be orphaned records and images, but the user will not see anything (except for the exception), and presumably would re-enter the expense report. In the meantime a background process will eventually clean up everything. Simple and efficient.

Comments

  • Anonymous
    May 11, 2010
    Thank

  • Anonymous
    May 11, 2010
    Why did you remove the try catch? You can handle the exception and show a user friendly message. Putting header save in the a nested try catch could help you track which part crashed and show an appropriate error message. Or is it just that you want to show an exception to the user to warn him that something went wrong, and the "beautification" of your code is left as an excercise for the reader? :)

  • Anonymous
    May 12, 2010
    The comment has been removed

  • Anonymous
    May 16, 2010
    The comment has been removed