tag:blogger.com,1999:blog-5888658295182480819.post8517694945014368413..comments2022-04-05T09:43:19.308-03:00Comments on Alaska Ataca a Kamtchatka: (Dis)Functional BowlingMatías Giovanninihttp://www.blogger.com/profile/17772004856076119446noreply@blogger.comBlogger11125tag:blogger.com,1999:blog-5888658295182480819.post-22060321369531543322009-07-25T12:56:56.554-03:002009-07-25T12:56:56.554-03:00@Javier: The Bowling kata is supposed to be a text...@Javier: The Bowling kata is supposed to be a textbook example of TDD. In my opinion, it derails from the moment they decide to model throws in an object-oriented way. But by all means look it up and form your own opinion.<br /><br /> @Scot: Whether TDD is compatible or not with FP is a matter of opinion, I think. Nothing in principle says they cannot go together. The majority of the Matías Giovanninihttps://www.blogger.com/profile/17772004856076119446noreply@blogger.comtag:blogger.com,1999:blog-5888658295182480819.post-13899838131902063052009-07-24T17:07:16.293-03:002009-07-24T17:07:16.293-03:00I like that infinite list trick... I didn't kn...I like that infinite list trick... I didn't know you could do this in OCaml. This is the sort of thing that Haskelers brag about, isn't it? Of course they've got nicer syntax for it, but one can imagine a camlp4 extension that would help in that department.<br /><br />So how exactly do infinite lists work in OCaml? Does OCaml just decide that after some number of recursions to Just A. Developerhttps://www.blogger.com/profile/04470979700183087584noreply@blogger.comtag:blogger.com,1999:blog-5888658295182480819.post-16519407132763377762009-07-22T20:43:06.271-03:002009-07-22T20:43:06.271-03:00To be fair, TDD isn't really meant to help muc...To be fair, TDD isn't really meant to help much with any program that can be expressed in 10 lines.assmanhttps://www.blogger.com/profile/13786741751730949083noreply@blogger.comtag:blogger.com,1999:blog-5888658295182480819.post-67451279204530316762009-07-22T12:13:48.148-03:002009-07-22T12:13:48.148-03:00@Scot
For functional testing check out Haskells&#...@Scot<br /><br />For functional testing check out Haskells' QuickCheck (IIRC, it's available in Scala too). There are some examples of its usage in Real World Haskell.dm3https://www.blogger.com/profile/15366444510753413450noreply@blogger.comtag:blogger.com,1999:blog-5888658295182480819.post-75269219149106682992009-07-22T07:17:50.064-03:002009-07-22T07:17:50.064-03:00I've tried doing TDD with Scala, and the one t...I've tried doing TDD with Scala, and the one thing I found was that it kept me from programming in a functional style. Maybe it was my lack of experience doing TDD with FP (and I never found any resources on the web - every TDD resource is TDD with OO), but I was left wondering if TDD is really compatible with FP.<br /><br />Perhaps TDD is all the rage because it papers over some flaws in OO Scot McSweeney-Robertshttps://www.blogger.com/profile/05078277004789544258noreply@blogger.comtag:blogger.com,1999:blog-5888658295182480819.post-64452351069206109182009-07-22T02:25:53.917-03:002009-07-22T02:25:53.917-03:00well i think tdd was designed for large business a...well i think tdd was designed for large business apps developed by teams of programmers, not for simple pieces of code. TDD can make the simple code ridiculously complex.<br /><br />But functional programming is approaching to business and may be TDD could help (or maybe not)Anonymoushttps://www.blogger.com/profile/03081252416288495482noreply@blogger.comtag:blogger.com,1999:blog-5888658295182480819.post-90679042186318139832009-07-21T14:19:07.981-03:002009-07-21T14:19:07.981-03:00@Tim: my using an infinite list was more of a show...@Tim: my using an infinite list was more of a show-off than anything. Notice that no bowling game can be longer than 21 balls, hence padding with at most 21 zeros suffice:<br /><br /><b>let rec repeat n x =<br><br /> if n = 0 then []<br><br /> else x :: repeat (n - 1) x<br><br /><br><br />let game strikes = strikes @ repeat 21 0<br /></b><br /><br />HTHMatías Giovanninihttps://www.blogger.com/profile/17772004856076119446noreply@blogger.comtag:blogger.com,1999:blog-5888658295182480819.post-65994819992305842252009-07-21T13:29:39.728-03:002009-07-21T13:29:39.728-03:00I'm interested in trying out your code but fsi...I'm interested in trying out your code but fsi version 1.9.6.16 is complaining about it:<br /><br />error FS0191: Recursive values may not appear directly as a construction of the type 'FSharpList`1' within a recursive binding. This feature has been removed from the F# language. Consider using a record instead.<br /><br />Would you please help an F# noob like me by showing how this Tim Stewarthttps://www.blogger.com/profile/09462164199588340287noreply@blogger.comtag:blogger.com,1999:blog-5888658295182480819.post-80068276239717248532009-07-21T13:29:11.491-03:002009-07-21T13:29:11.491-03:00Ten lines of code to solve this problem compared t...<i>Ten lines of code to solve this problem compared to Bob Martin's bumbling is an absolute indictment of OO and TDD, in my book.</i><br /><br />Don't forget that Clojure lacks pattern matching, which makes a bit less comfortable than members of the ML family (multimethods just don't fit for some problems).Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5888658295182480819.post-1238688892321212512009-07-21T12:59:19.688-03:002009-07-21T12:59:19.688-03:00@Anonymous: The rules of the actual game were clea...@Anonymous: The rules of the <i>actual game</i> were clearly defined, the "modeling of a real-world problem" was not. I had complete design freedom, and that's what TDD is supposed to guide you in. Utterly unnecessary.<br /><br />Ten lines of code to solve this problem compared to Bob Martin's bumbling is an absolute indictment of OO and TDD, in my book.Matías Giovanninihttps://www.blogger.com/profile/17772004856076119446noreply@blogger.comtag:blogger.com,1999:blog-5888658295182480819.post-48382677345346909412009-07-21T12:49:37.009-03:002009-07-21T12:49:37.009-03:00Look the problem was already clearly defined. The ...Look the problem was already clearly defined. The definition exists! TDD isn't needed if you already have a clear problem. <br /><br />TDD is really about a lack of requirements elicitation and using tests to make up for it.<br /><br />Really you could've just done test first, yet TDD was unnecessary because you even had test cases already made!<br /><br />assert 133 = somegameAnonymousnoreply@blogger.com