benno has asked for the wisdom of the Perl Monks concerning the following question:
As part of coding quality control we set up a constants file for record references shared between modules (and developers). So the above is rendered$r->{thisid} = 10; $r->{this_id} = 10;
Incorrect field indexes entered by bleary eyed developers in such asuse constant ID =>'thisid'; . . $r->{(ID)} = 10; . .
Will be immediately picked up by the compiler in development and not in production. ..... However This constants file in near 400 lines long and growing. Do the monks have any opinion on whether this was a reasonable strategy or is there a better way to ensure the same level of development robustness? Benno UPDATE - what I actually did Firstly I reread the perl documentation on exporting. Then I split the constants file into logical modules. In my case these were XML tokens, default setting and system tokens. Then I went through each module and changed the blanket includes to be more specific. Since there were 70 modules I wrote some helper scripts to find where the constants were being used and the automatic generation of the header include from within VI using the .!sh command. If anyone wants these I'll post later.$r->{(THISID)}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Advice on Global Constants
by perrin (Chancellor) on Jun 16, 2007 at 15:30 UTC | |
|
Re: Advice on Global Constants
by FunkyMonk (Bishop) on Jun 16, 2007 at 16:13 UTC | |
|
Re: Advice on Global Constants
by wind (Priest) on Jun 16, 2007 at 16:32 UTC | |
|
Re: Advice on Global Constants
by shmem (Chancellor) on Jun 17, 2007 at 09:35 UTC | |
|
Re: Advice on Global Constants
by apl (Monsignor) on Jun 16, 2007 at 15:11 UTC | |
|
Re: Advice on Global Constants
by andreas1234567 (Vicar) on Jun 17, 2007 at 09:53 UTC | |
by benno (Novice) on Jun 17, 2007 at 11:08 UTC | |
|
Re: Advice on Global Constants
by syphilis (Archbishop) on Jun 17, 2007 at 12:47 UTC |