2012-02-07, 12:52 PM
Rather then littering Iain's original thread was endless posts and comments on the "tricks", I created this thread as a the garbage can, allowing people to follow up.
Hi Brian,
As a self-taught C# programmer, who never used it before creating the original WebRadio plugin for PVRx2 could you explain why it is a bad idea as a self-improvement tool. I probably have lots of bad practices and I do want to improve.
In my code I would say I don't trap 95% of the individual commands that could return an error, I group them, since I try and structure my code with one return per function and many catches with lots of ifs would make it almost unmaintainable. When I do a trap most of the time it is just a Logger.Debug(e.Message) which hardly impacts the program flow. Isn't that really the same as an empty catch? I did adopt my own notation of catch {} on one line to show that it was empty so that I wouldn't accidentally think the following non-indented code was the catch.
In the example I gave http://forums.nextpvr.com/showthread.php...post430834, both precdeding lines could return exceptions and I really should have been looking for a 404 etc, but ultimately what I am concerned about is the string returned is valid xml, and when the doc.Load(strContent) fails in the next line I do handle that.
Martin
bgowland Wrote:Hmm, it's time I retired so I won't go into details about why having empty catch blocks or a 'catch all' block are really bad ideas. Not good practices to teach people based on Iain's opening statement and the spirit of this thread.
Cheers,
Brian
Hi Brian,
As a self-taught C# programmer, who never used it before creating the original WebRadio plugin for PVRx2 could you explain why it is a bad idea as a self-improvement tool. I probably have lots of bad practices and I do want to improve.
In my code I would say I don't trap 95% of the individual commands that could return an error, I group them, since I try and structure my code with one return per function and many catches with lots of ifs would make it almost unmaintainable. When I do a trap most of the time it is just a Logger.Debug(e.Message) which hardly impacts the program flow. Isn't that really the same as an empty catch? I did adopt my own notation of catch {} on one line to show that it was empty so that I wouldn't accidentally think the following non-indented code was the catch.
In the example I gave http://forums.nextpvr.com/showthread.php...post430834, both precdeding lines could return exceptions and I really should have been looking for a 404 etc, but ultimately what I am concerned about is the string returned is valid xml, and when the doc.Load(strContent) fails in the next line I do handle that.
Martin