[BioRuby] (no subject)

Moses Hohman mmhohman at northwestern.edu
Tue Jan 31 17:25:56 UTC 2006


Hi Pjotr,

I completely agree. We should throw an exception.

Moses

On Jan 31, 2006, at 1:30 AM, Pjotr Prins wrote:

> Dear all,
>
> In the tutorial we write:
>
>   So when using String methods, you should subtract 1 from positions
>   conventionally used in biology.  (subseq method returns nil if you
>   specify positions smaller than or equal to 0 for either one of the
>   "from" or "to".)
>
> and I added:
>
>   (EDITOR'S NOTE: should 'subseq' not throw an exception instead?)
>
> Can someone state what is the preferred design? I personally think an
> exception should be thrown to warn a programmer something is wrong -
> i.e. this is an exceptional situation ;-). Returning a nil may lead to
> nicer looking loops, but it does not help writing good programs.
>
> Regarding the exception vs return code issue, I think Martin Fowler's
> Refactoring says all that need to be said :
>
> - Returning an error code to indicate an error is a code smell because
> 	you could miss the error checking
> 	(http://www.refactoring.com/catalog/...hException.html)
>
> - Throwing an exception on a condition the caller could have checked
> 	first is another code smell because it makes the caller code hard
> 	to read
> 	(http://www.refactoring.com/catalog/...onWithTest.html)
>
> Pj.
> _______________________________________________
> BioRuby mailing list
> BioRuby at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioruby
>




More information about the BioRuby mailing list