Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Feature or Bug ?

by ady (Deacon)
on Sep 17, 2005 at 08:16 UTC ( [id://492820]=note: print w/replies, xml ) Need Help??


in reply to Feature or Bug ?

Question: Suppose also that my faulty implementation of my faulty algorithm will give the proper output on all input. -- Does my program have a bug ?

The input/output function (the mapping from one set of values to another) is the mathematical definition of behavioural correctness of a program transformation. If your implementation (as stated) performs the transformation as specified, it is correct from a black box perspective.

Example:
A program with following i/O behaviour (i=>o mapping) performs a doubling finction on the integer range 1..4:
1=>2 2=>4 3=>6 4=>8
The following program performs the i/o transformation as specified; It is "black box correct".
# Faulty Algorithm: double int's in range [1..4] my %hDouble = (1=>'2', 2=>'4', 3=>'7', 4=>'8'); # Kinky Perl computation: assert (&& thus fix) algorithm for my $i (1..4) { my $o = $hDouble{$i}; $o-- if ($o%2 != 0); print $i . "=>" . $o . "\n"; }
Opening the box we can observe that the doubling algorithm (a lookup table) is flawed and the Perl code is unnecessarily complex and shaky. From a white box perspective the implementation is of poor quality : the bugs cancel out each other (from the black box perspective), but the code should definitely be cleaned up for better maintainability, robustness and efficiency.

That in a way brings us back to your Larry Wall quote: ...redundancy was absolutely necessary to achieve the goal of putting someone on the moon. Use pair programming, technical walkthroughs, reviews... any and all human redundancy to assure "white box quality" of the implementation (ie. to catch - among other things - bugs cancelling out each other as seen from a pure interface/black box view. And for certain systems (as rocket science): use hardware redundancy as well, because only relatively small applications can be mathematically proven to be even black box (I/O transformation) correct, much less white box so.

Allan

If a tree falls in a forest with no one to hear it, then does it make a sound?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-18 06:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found