Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any modules I'm missing to help me write better code?

I'm using the following command to test my perl code:

perl -MB::Lint::StrictOO -MO=Lint,all,oo -M-circular::require -M-indirect -Mwarnings::method -Mwarnings::unused -c $file

On a system with a perl version less than 5.10 I am also using uninit.

I am also using Perl::Critic and Perl::Tidy and have set up the appropriate rc files to my liking.

These modules have done a great job in helping me break some bad habits I learned when first learning perl.

Are there any more modules or pragmas that will kick me back on the straight and narrow when I mess up?

Using tests, and the Test::* family of modules and some good books have been pointed out. This new information has caused me to reconsider some assumptions about the relationship between testing and code skill building. These are all appreciated and already being researched and put to use.

It seems to me that these are two separate parts of a whole. 'perl -c', Perl::Critic and Perl::Tidy all help during the process of writing code and before execution of code. Devel::Cover, Devel::NYTProf and Tests happen during and after execution of code.

Good development dictates an iterative process, so tests will be run, and code developed over and over, but we still have this separation.

It appears to me that the focus in the answers have been on the 'during and after execution' of code. Again, this is very appreciated. Can I assume that I have the 'writing and pre-execution' part down pretty well then? At least, insomuch as the pragmas, modules and utilities are concerned.

like image 517
harleypig Avatar asked Jul 20 '12 02:07

harleypig


2 Answers

I'm a little worried that you're using Perl 5.9. For two reasons.

Firstly it's a little old. 5.9.0 was released in 2003 and 5.9.5 (the last version in the 5.9.x series) was released in 2007. There have been several high quality versions of Perl since then.

Secondly (and most importantly), 5.9 is an unstable development version of Perl. 5.9 is basically the series of experiments that eventually led to Perl 5.10.0. The only reason to use it is to test that 5.10 will be a stable version of Perl. No-one should be using it at all now.

like image 134
Dave Cross Avatar answered Oct 14 '22 15:10

Dave Cross


You don't appear to be testing your code, merely checking that it will compile. I suggest that you look at Test::More (which makes writing actual tests nice and easy), Test::Class (which makes dealing with very large test suites easier), and Devel::Cover (to see which bits of your code are covered by your tests and which aren't).

like image 24
DrHyde Avatar answered Oct 14 '22 15:10

DrHyde