tag:blogger.com,1999:blog-32079676.post3044150342883615981..comments2024-02-13T21:22:02.522-08:00Comments on RRResearch: Reading codeRosie Redfieldhttp://www.blogger.com/profile/06807912674127645263noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-32079676.post-61354510126486319502008-04-17T18:45:00.000-07:002008-04-17T18:45:00.000-07:00@rosie yeah, we have feed things :)You're in the "...@rosie yeah, we have feed things :)<BR/><BR/>You're in the "open science" category of my Google Reader. The web is always watching and waiting.Neilhttps://www.blogger.com/profile/14642902803329530119noreply@blogger.comtag:blogger.com,1999:blog-32079676.post-44258885384297681292008-04-17T16:56:00.000-07:002008-04-17T16:56:00.000-07:00Have you guys been hanging around all term, waitin...Have you guys been hanging around all term, waiting for me to drag myself away from my teaching long enough to post something? Or do you have a feed thing, so you know when I post?<BR/><BR/>I like the idea of building in tests. The undergraduate has been doing tests, but not in an organized way and not building them into the code or writing the results up in a notebook.<BR/><BR/>He's not bad about including comments, but they're not as clear and unambiguous as they need to be for me. He's been having to work without proper oversight, but that's about to change.<BR/><BR/>I find it much easier to be disciplined about bench-work than about computer work. He hasn't learned this kind of discipline yet.<BR/><BR/>The program is broken down into components, but not as clearly as it could be. But he is using Strict; the typos are only in comments.Rosie Redfieldhttps://www.blogger.com/profile/06807912674127645263noreply@blogger.comtag:blogger.com,1999:blog-32079676.post-84010868339241766972008-04-17T02:37:00.000-07:002008-04-17T02:37:00.000-07:00I agree wholeheartedly with neil's advice. Further...I agree wholeheartedly with neil's advice. Furthermore, while your program remains a work in progress there are other things you can do to ensure it does what you intend (and nothing else!)<BR/><BR/>As it's Perl I'm assuming that you do <I>use strict</I> (and thus those typos that you mentioned could not be typos in variable names!)<BR/><BR/>Aim to write a program that is broken down into functions that each do well-defined operations e.g.<BR/><BR/>choose_fragment($genome, $frag_length)<BR/><BR/>mutate_fragment($frag, $mut_parameters)<BR/><BR/>insert_fragment($frag, $genome, $position)<BR/><BR/>and so on.<BR/><BR/>All these functions should have a test that confirms that they do their job e.g. test_choose_fragment might test that choose_fragment returns fragments of the expected size, conforming to an expected distribution of genomic positions.<BR/><BR/>Every time a significant bug is fixed a new test should be added that specifically confirms this by testing the condition that exposed the original error.<BR/><BR/>This sounds like extra work, but it will save you time in the long run. You will have confidence in the correctness of your program, freeing you to work on the biological question. With testing, your program can be modified more easily - just run all the tests after any changes.<BR/><BR/>Initially, don't worry about performance, rather focus on clarity and correctness.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-32079676.post-20144413441863914092008-04-16T20:28:00.000-07:002008-04-16T20:28:00.000-07:00Readability is vital, especially when code is shar...Readability is vital, especially when code is shared around. Perl is a bit notorious for being hard to read, but this can be improved by good commenting, or inline documentation (to be read using "perldoc myprogram").<BR/><BR/>Make sure your student understands the value of documentation. They should also commit the code to a repository using a version control system such as SVN; this will make them more disciplined and be useful for others who may need to read, modify or use it.<BR/><BR/>Be prepared also for a bunch of people telling you that an advantage of Python is its readability :)Neilhttps://www.blogger.com/profile/14642902803329530119noreply@blogger.com