Skip to Content.
Sympa Menu

devel - [sympa-developpers] ugly code

Subject: Developers of Sympa

List archive

Chronological Thread  
  • From: Guillaume Rousse <address@concealed>
  • To: address@concealed
  • Subject: [sympa-developpers] ugly code
  • Date: Mon, 22 Jul 2013 14:53:56 +0200

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. 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.

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);

--
Guillaume Rousse
INRIA, Direction des systèmes d'information
Domaine de Voluceau
Rocquencourt - BP 105
78153 Le Chesnay
Tel: 01 39 63 58 31

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




Archive powered by MHonArc 2.6.19+.

Top of Page