Skip to Content.
Sympa Menu

devel - Re: [sympa-developpers] ugly code

Subject: Developers of Sympa

List archive

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

Le 22/07/2013 15:04, David Verdin a écrit :

Le 22/07/13 14:53, Guillaume Rousse a écrit :
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.
I refrained myself from writing 'crap'... Sorry, it was unecessarily rude.

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.
Then we probably need some renaming, or a better definition of what is a site, what is a list, and what is a robot. Because I don't see any explicit relationship between a site and a mailing-list...

If the goal is just to share some code between those instance, the base class should probably called 'ConfigurableObject', for instance. And if sharing also means cluttering the code with 'what-kind-of-entity-am-i-called-upon', you lose all interest of code ruse.

BTW, code reuse should just be a side-effect of object modeling, not its driving pattern. For instance, I prefered to duplicate the methode to compute DBI connection string in Sympa::Database::* and Sympa::Datasource::* subclasses, just to make clearer than there isn't any relationship between the sympa mandatory database, and potential external sources.
--
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