[BioRuby] named arguments

Toshiaki Katayama ktym at hgc.jp
Thu Nov 15 08:51:29 UTC 2007


Jan,

There are several methods which accept hash as the last argument, so you are OK to proceed with it.

Toshiaki

On 2007/11/15, at 5:05, jan aerts ((RI)) wrote:

> Hi staff,
>
> We think we're getting to a good workable version of Bio::Graphics. However, we also bumped into a distinctive feature of a library like Bio::Graphics: its methods have to be highly configurable. What should be the colour of the genes, what glyph should be used (spliced, a line, ...), what's the label that should be displayed, ... As a result, the argument lists for many of the methods become unwieldingly long and cumbersome to use. This is most apparent when the user of the library wants to use all default values for a method, except one which happens to be the last one in the argument list. The user has to write code like this (a little bit exaggerated, but still...):
>
>   picture.add_gene(my_gene, nil, nil, [], nil, nil, [], [], nil, {}, [], :green)
>
> A good workaround is to use named parameter lists, which would make the previous code look like:
>
>   picture.add_gene(:feature => my_gene, :colour => :green)
>
> which is much more readable.
>
> However, I'm a bit squeemish of doing it this way, because it would be a different paradigm than the one that bioruby uses. What do you guys think about integration of bioruby and Bio::Graphics somewhere in the future? Would the fact that we'd implement named argument lists in Bio::Graphics make integration into the bioruby toolkit difficult/impossible/not a good idea?
>
> Really looking forward to your comments.
> jan.




More information about the BioRuby mailing list