Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Perl Skills

by hesco (Deacon)
on Jun 15, 2010 at 05:40 UTC ( #844787=note: print w/replies, xml ) Need Help??


in reply to Perl Skills

At the risk of adding to an already ambitious syllabus, may I suggest that you create a simple module which fills some personal need and build a test suite providing 100% coverage of your code base. I found that a very useful exercise in many ways.

-- Hugh

P.S.

In response to Moritz, yes, achieving 100% coverage is not always possible -- even when I invest the time and energy, but the quest for that goal has proven very educational for me. And it has never hurt my code base to have better coverage.

if( $lal && $lol ) { $life++; }
if( $insurance->rationing() ) { $people->die(); }

Replies are listed 'Best First'.
Re^2: Perl Skills
by moritz (Cardinal) on Jun 15, 2010 at 11:56 UTC
    100% coverage isn't always achievable.

    For example I put Carp::confess statements in some of my modules to catch internal errors. When my module works fine, there is simply no way to trigger them. They are dead code.

    Still they are very useful, because when I change something and break the module, I get much better error messages than without those statements.

    One could try to trigger thee cases by monkey-patching the module to misbehave, but I think that's a rather foolish idea.

      Our way to reach 100% coverage is the following:

      1. we do module-test to cover as near as 100% as possible
      2. if we reach less than 100% (this is the normal case), we analyze/review all parts that were not covered by the test
        • if we discover testing-gaps, we enhance the module test
        • if some code is really not testable, but OK according the analysis/review, we consider it covered
      With that proceeding it is always possible to reach the 100% coverage. And I don't think it is cheating ;-)

      HTH, Rata

Re^2: Perl Skills
by eyepopslikeamosquito (Chancellor) on Jun 17, 2010 at 21:44 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://844787]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2018-07-19 17:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (414 votes). Check out past polls.

    Notices?