Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Philosophical question about testing

by Monkomatic (Sexton)
on Oct 27, 2010 at 23:56 UTC ( [id://867870]=note: print w/replies, xml ) Need Help??


in reply to Philosophical question about testing

One of the few quirks with perl is that:

The 20 line code you wrote 4 weeks ago.

Becomes a 15 line code 2 weeks later.

Then 1 week later you discover how to do it in 2 lines.

And then someone (usually on this very forum) points out that it is possible in 1.

This is why modules and subs arent talked about much

So I wouldn't really stress the Philosophical side of modules. Do it to help understand how to share your code with the community when you have code you wish to share. (CPAN)

  • Comment on Re: Philosophical question about testing

Replies are listed 'Best First'.
Re^2: Philosophical question about testing
by dsheroh (Monsignor) on Oct 28, 2010 at 08:55 UTC
    While your given "quirk" is true (TIMTOWTDI and all), I draw exactly the opposite conclusion from it: When there are many ways to do something, the philosophical side helps to decide which is the appropriate way in any given situation.

    More relevantly to the original question, being likely to change the implementation of a method over the lifetime of the code means that it's less of an issue if your testing code mirrors the (original) implementation, since it will still assure you that the method produces the same results after its implementation is changed. (But, that said, I agree with earlier responses that this particular case sounds like one in which breaking the code down further into finer-grained methods and testing those smaller pieces independently is the way to go.)

Re^2: Philosophical question about testing
by doom (Deacon) on Oct 29, 2010 at 17:36 UTC

    This is why modules and subs arent talked about much
    Modules and subs are talked about all the time by perl programmers who have half a clue about what they're doing.

    If you push a block of code off into a sub inside a module, among other things you'll discover that it's much easier to write tests for it, and once you've got tests for it, it's much easier to re-write it as you describe (though reducing line count is hardly ever the first priority).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://867870]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (7)
As of 2024-04-16 07:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found