in reply to Re^9: Perl Best Practices
in thread Perl Best Practices
From the articles...
Every time you call a function that can raise an exception and don't catch it on the spot, you create opportunities for surprise bugs caused by functions that terminated abruptly, leaving data in an inconsistent state, or other code paths that you didn't think about....and...
Note that the errors arise when the exception disrupts the sequencing of side effects. No side-effects (like state), no problems.Here's what it might look like after you fix it to be correct in the face of exceptions:NotifyIcon CreateNotifyIcon() { NotifyIcon icon = new NotifyIcon(); icon.Text = "Blah blah blah"; icon.Visible = true; icon.Icon = new Icon(GetType(), "cool.ico"); return icon; }NotifyIcon CreateNotifyIcon() { NotifyIcon icon = new NotifyIcon(); icon.Text = "Blah blah blah"; icon.Icon = new Icon(GetType(), "cool.ico"); icon.Visible = true; return icon; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^11: Perl Best Practices
by wazoox (Prior) on Jul 20, 2005 at 17:17 UTC | |
by Anonymous Monk on Jul 20, 2005 at 18:20 UTC |
In Section
Perl News