in reply to Defensive Programming
One thing that I've trained myself to do, which isn't so much defensive programming in construction, but more of a habit, is to mirror resource calls right away. For instance, if I'm writing code to process a file, I'll write:
and then fill in the code between the open and the close. (And yes, 3-arg open is safer, but it's not available on my target.) I do the same thing with DBI connects and the like. --open FILE, "<$filename" or die "Can't open $filename: $!\n"; close FILE or die "Can't close $filename: $!\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (FoxUni) Re: Defensive Programming
by theorbtwo (Prior) on Jan 15, 2002 at 00:42 UTC |