Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

The cure would be worse than the disease

by dragonchild (Archbishop)
on Mar 14, 2003 at 14:33 UTC ( #243057=note: print w/ replies, xml ) Need Help??


in reply to Assertions?
in thread Fun with Hook::LexWrap and code instrumentation

Doing this by hand would be a complete PITA

No. Doing this would be

  1. a complete waste of time
  2. counter-productive
  3. a case of the cure worse than the disease
Every time you add a line of code, you have a non-zero (and often deceptively large) chance of introducing a bug. Let's say that you're a really good programmer and your error rate for development is 1 bug for every 20 lines of code*. If you add 100 assertions to find one bug (assuming that Foo is used in 100 places), then you just (potentially) added another five bugs, just as hard to track. (Possibly harder, because everyone assumes that bugfix code isn't buggy.)

In addition, you now have a maintenance nightmare. Let's say that I'm your maintenance programmer. I go in and realize I need to now modify Foo somewhere. I have 24 hours to get this bug fixed. I don't know about your assertions thing. All I know is that I can fix the bug by hacking at your pretty object. Boom! Your entire assertions framework fails.

Using Hook::LexWrap (and similar techniques) is vastly preferable to adding assertions by hand, for just these reasons.

* Error rates gleaned from Code Complete on p. 610. Steve McConnell says that delivered code generally has 15-50 defects per 1000 lines. He also says that the Apps Division at MS has 10-20/1000 during in-house testing and 0.5/1000 in released code. That's a 30-1 ratio between development and release for a stringent regime. A lax regime will probably have a 10-1 ratio. Thus, a standard programmer during development will probably have 350-500 defects per 1000 lines of code. A really good one will be at 50/1000, or 1/20 lines of code.

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.


Comment on The cure would be worse than the disease
Re^2: Assertions?
by adrianh (Chancellor) on Mar 14, 2003 at 15:00 UTC

    All true.

    One of the many things that excites me about perl6 is that it looks like you'll be able to implement proper class invarients and contracts ala Eiffel with the subroutine wrapping stuff. Nice.

    That's not to say I'm not looking forward to a sensible assertion mechanism in the next perl5. Although my first thought when I saw it was to use it for logging ;-)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2014-08-29 17:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (283 votes), past polls