Re: TDD for numerical algorithms
"Neil" <[email protected]> Thu, 27 May 2010 14:03:07 -0000
| Newsgroups | gmane.comp.programming.refactoring |
|---|---|
| Message-ID | <[email protected]> |
As the other posters have said or implied, you can't really TDD your way to a specific random number algorithm IF your specification is just that you want a random number generator. (I'm ignoring for now the difficulties inherent in choosing "random" test cases.)
If you want to use TDD, use it on the properties of the specific algorithm to get your algorithm(s) for the various pieces, e.g., matrix linear recurrence or finite binary fields. Then use test first tests to verify that they're put together correctly and test after tests to verify that they produce a uniform distribution.
For these sorts of algorithms in general, I like a combination of TDD and design by contract (Bertrand Meyer's Object-Oriented Software Construction or [better] David Gries's The Science of Programming) with the contracts/(pre/post)conditions/invariants guiding the tests.
Neil
--- In [email protected], Richard <legalize@...> wrote:
>
> OK, I know this isn't strictly refactoring and more of a TDD question,
> but I don't know of a forum specifically for TDD.
>
> How would you use TDD to implement the Mersenne twister random number
> generator? <http://en.wikipedia.org/wiki/Mersenne_Twister>
>
> In particular, I'm curious as to what kind of test cases you would write.
>
> --
> "The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
> <http://legalizeadulthood.wordpress.com/the-direct3d-graphics-pipeline/>
>
> Legalize Adulthood! <http://legalizeadulthood.wordpress.com>
>
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/refactoring/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/refactoring/join
(Yahoo! ID required)
<*> To change settings via email:
[email protected]
[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/