Skip to Content.
Sympa Menu

devel - Re: [sympa-developpers] ugly code

Subject: Developers of Sympa

List archive

Chronological Thread  
  • From: David Verdin <address@concealed>
  • To: address@concealed
  • Subject: Re: [sympa-developpers] ugly code
  • Date: Mon, 22 Jul 2013 15:04:33 +0200


Le 22/07/13 14:53, Guillaume Rousse a écrit :
address@concealed">In Sympa::site:


sub get_etc_filename {
    Log::do_log('debug3', '(%s, %s, %s)', @_);
    my $self    = shift;
    my $name    = shift;
    my $options = shift || {};

    unless (ref $self eq 'List' or
    ref $self eq 'Family' or
    ref $self eq 'Robot'  or
    $self     eq 'Sympa::Site') {
    croak 'bug in logic.  Ask developer';
    }
}

That's absolutly ugly.
:-)     
I love the way we can speak to each other without fearing ego fights. I see it as a sign of good health for the Sympa project.
address@concealed"> Unless there is a class relationship between Sympa::List, Sympa::Family, Sympa::Robot and Sympa::Site, those methods should be defined separatly in those different classes, and should not spend CPU cycles testing if they have been invoked on a correct instance.
That seems to make sense, however I don't remember the exact relationship between these classes.
If I remember correctly, list and Robot both inherit Site. i don't think Family inherits anything.
address@concealed">
Morevoer, testing if an instance belongs to a class with 'eq' is wrong, as it will fails to recognize a subclass. You should use isa() method instance:
if $self->isa("Sympa::List);
Agreed too, We tend to use it more and more but we there are probably still some code like this here and there; We'll track them down ASAP.

--
A bug in Sympa? Quick! To the bug tracker!

 
David Verdin
Infrastructure pour les Services Informatiques
 
Tél : +33 2 23 23 69 71
Fax : +33 2 23 23 71 21
 
www.renater.fr
RENATER
263 Avenue du Gal Leclerc
35042 Rennes Cedex



PNG image

Attachment: smime.p7s
Description: Signature cryptographique S/MIME




Archive powered by MHonArc 2.6.19+.

Top of Page