in reply to Tip: Create a "working" perl lib for your personal use
package Foo; sub returnANumber { return 66; } package FooUser; use Foo; if (Foo::returnANumber() < 82) { # do something } else { # do something entirely dependent upon returnANumber being an intege +r > 0 && <= 100... }
Recommendation #1 is to write tests and package them alongside your scripts to ensure that one travels with the other. Or you could just store them inside a DATA segment at the end of a script...
#!/usr/bin/perl -w use strict; use Getopt::Long; my ($aa, $bb, $diagnostic) = (undef, undef, 0); if (@ARGV){ GetOptions('aa=s'=>\$aa, 'bb=s'=>\$bb, 'diagnostic'=>\$diagnostic); } if ($diagnostic){ my $test = ''; while(<DATA>){ $test .= $_; } eval($test); die 'Ran tests. Done.'; } 1; __DATA__ use Test::More qq~no_plan~; ok(1==1,'basic'); 1;
"Then get right back to work. I no longer have to worry about whether my tests are including the right path to my modules..."
Unfortunately this is the problem I run into all to often. Developers and support people do all of the right things...they write tests, they modularize their code; they store things in separate libraries on a hard drive. All good. Problem: what happens if you take another job?
I get it. People say, 'well...I wrote that stuff to facilitate my work; the next person is just gonna have to figure out my stuff or cook up their own...' Yep. And the next person shows up on Perlmonks with 30 questions about how X, Y, and Z works.
You specified your workflow and even enumerated the points. Here is where I think it falls short:
The last one is a bit tricky because it depends a lot on the industry you are working in. If you are in some engineering firm you might find that there are numerous conditions that no one has thought about that will force you to refactor code a lot. In that case you might find you have to keep your code in some smaller pieces that can be mashed together at some later point.
Celebrate Intellectual Diversity
|
---|