[Bioperl-l] Inconsitency in return value ofBio::SimpleAlinment::remove_columns()
Chris Fields
cjfields at uiuc.edu
Fri Sep 22 18:56:32 UTC 2006
> -----Original Message-----
> From: bioperl-l-bounces at lists.open-bio.org [mailto:bioperl-l-
> bounces at lists.open-bio.org] On Behalf Of Seiji Kumagai
> Sent: Friday, September 22, 2006 1:13 PM
> To: bioperl-l at lists.open-bio.org
> Subject: [Bioperl-l] Inconsitency in return value
> ofBio::SimpleAlinment::remove_columns()
>
> Hi list,
>
> Yesterday, I reported a small bug relating to
> Bio::SimpleAlign::remove_columns(). My patch was committed to CVS
> immediately thanks to Chris.
>
> I, at the same time, noticed another issue with the method. According to
> the POD, the method returns a new alignment. However, iff argument is not
> passed to it, the return value is $self. I see this may be a problem
> because modifications on the returned value affect the original object
> only if this method is called in the way I mentioned. Secondly, it is just
> confusing to me that returned value is different but superficially
> identical (both are Bio::SimpleAlignment object).
>
> I want to make a modification on this issue by one of the following ways:
>
> 1) Make an argument mandatory. If argument is missing, throw an
> exception. It is user's responsibility to handle it properly.
>
> 2) Always return new SimpleAlign object. If the argument is not passed,
> return a clone of $self. This may make the scripts run slower and use more
> memory when no argument is given, but modification on new object is
> guaranteed not to affect original object.
>
> 3) Do not modify current version.
>
> 3.a) Do not modify current version, but state the difference in POD.
>
> What do you think? I personally think the first is the best since calling
> the method but doing nothing is not what users want to do in most of the
> cases. Those rare cases are deserved to be handled by an exception.
>
> Thanks,
The first option sounds appropriate considering the use of the method in
POD. I also agree that returning $self isn't the best practice either,
since it would not be a true clone of the object (unless there is some deep
copy magic going on that I don't see).
What would you suggest?
Christopher Fields
Postdoctoral Researcher - Switzer Lab
Dept. of Biochemistry
University of Illinois Urbana-Champaign
More information about the Bioperl-l
mailing list