in reply to Structural Elegance
Oddly enough, this is no longer an issue that concerns me. With proper test suites in place, I have, on a number of occasions, made large, sweeping changes in my code. Knowing you'll catch any bugs you make with a test suite substantially reduces "fear based programming."
As a side note, I noticed this:
I woke up in the middle of last night worrying about whether I'd trashed a data variable I was merrily carrying along through a control sequence just because it was ...
That sounds suspiciously like "tramp data." Tramp data is data that is passed, unused, through a call chain so that the later methods/subroutines can get access to it. This is a Bad Thing. Your code becomes more difficult to refactor because subs now take extraneous arguments. Also, if you accidently munge the data, it can be difficult to track down where this happened.
Instead, use access subroutines to handle this:
my $TRAMP; sub my_data { $TRAMP = shift if @_; return $TRAMP; }
You can then take the variable out of the call chain. Later, if you find something is altering this data in an unexpected manner, you can put data validation here, dump stack traces, etc.
Cheers,
Ovid
New address of my CGI Course.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Structural Elegance
by zby (Vicar) on Apr 20, 2005 at 20:09 UTC | |
by BrowserUk (Patriarch) on Apr 20, 2005 at 20:26 UTC | |
by TimToady (Parson) on Apr 20, 2005 at 22:18 UTC | |
by BrowserUk (Patriarch) on Apr 20, 2005 at 22:27 UTC | |
by Ovid (Cardinal) on Apr 20, 2005 at 23:31 UTC | |
| |
by Ovid (Cardinal) on Apr 20, 2005 at 23:29 UTC | |
|
Re^2: Structural Elegance
by samizdat (Vicar) on Apr 20, 2005 at 20:25 UTC | |
|
Re^2: Structural Elegance
by Anonymous Monk on Apr 21, 2005 at 19:15 UTC |