Here's a question to expose my lack of experience: I have a DoSomething () method that throws an exception if it fails to do this cleanly. If this fails, I try several times to use the less accurate DoSomethingApproximately () method in the hope that it will find a reasonably good solution; if this also fails, I finally call DoSomethingInaccurateButGuaranteedToWork () . All three are methods belonging to this object.
Two questions: first, is this a (admittedly ugly) template, or is there a more elegant way?
Secondly, what is the best way to keep track of how many times I called DoSomethingApproximately () , given that this could throw an exception? I am currently storing the iNoOfAttempt variable in an object, and the nested try blocks ... this is terrible and I'm ashamed.
source
share