# Re: Is Your Software Working A Little Too Predictably?

**URL:** <https://www.ruby-forum.com/t/re-is-your-software-working-a-little-too-predictably/84035>\
**Category:** Ruby\
**Created:** [March 20, 2006, 3:31am UTC](https://www.ruby-forum.com/t/re-is-your-software-working-a-little-too-predictably/84035 "2006-03-20T03:31:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 20, 2006, 3:31am UTC](https://www.ruby-forum.com/t/re-is-your-software-working-a-little-too-predictably/84035/1 "2006-03-20T03:31:50Z")

</div>

Hi,

Bernhard, Simon: I like the idea of reducing the pool of available  
methods. The test for arity is nice too, which could be done at the  
start or as the pool is reduced, but I like my software to my work for  
me sometimes and for the sake of clarity even if at the sake of  
efficiency, hence rescue rather than testing first. Although, it is  
good to know why something has ‘gone wrong’ or to explicitly prevent  
that too.

Joel: I had similar ideas for the purpose of constructing intelligent  
autonomous networks of code… Assume you have (untrained) monkeys at  
keyboards at one end and hope to have something sensible at other given  
enough decent filters, er DuckWeed? (A little enviro joke for all you  
ecologists and environmental engineers out there… Any?)

Expect to see something like this in wacky (but good, useful—no really  
this time… Hint, it’ll do something other than p.) stuff soonish…

The more pressing need (or just simply what I referred to at the bottom  
of that post) is for code to randomly ‘rewrite’ methods to point to  
other methods. Then one’s code doesn’t need to explicitly refer to  
random\_method and Test::Unit is automatically confused as soon as  
include RandomMethodOrSimilar is dropped in.

It would be good to combine the reducing pool of methods into  
DuckDebugging. Another idea for DD is to change the number of  
parameters, randomly or sequentially.

Oh and yeah, I didn’t need that methods = self.methods line: I was  
trying to make things obvious, but ended up being awfully redundant.

thoran

P.S. Excuse the lack of quoting below as ruby-talk \> /dev/null due to  
volume… I just read it off the web presently.

Why stop there?

$DEBUG=false  
$SAFE=3

# On the theory that if something goes wrong, you should just

# try something else until you find something that works.

module DuckDebugging  
def method\_missing(meth, \*args, &block)  
m = methods  
meth2 = m[rand(m.size)]  
result = send(meth2, \*args, &block)  
rescue =\> ex  
p [self, meth2, args, ex] if $DEBUG  
retry  
else  
p [self, meth2, args] if $DEBUG  
result  
end  
end

class Object  
include DuckDebugging  
end

result = (now your program can be any batch of garbage  
just enter words at random and you will get something)

p result
