[Gajim-devel] #2 Refactoring Newsletter
Stephan Erb
steve-e at h3c.de
Sat Nov 28 08:49:59 CET 2009
Hey everybody,
this mail has been sitting in my Drafts folder for much to long (since
16.11)....
== What I have done "last" week ==
I have focused mostly on PEP and Contacts.
* The Groupchat-related behavior of the Contact class was moved to
a separate GC_Contacts class. (Similar to what was done to the
Metacontact handling)
* The classes Contacts and GC_Contacts are now 'account
insensitive'. This means, they no longer handle contacts for
different accounts internally, but instead we create an instance
for each account. This removed quite some duplicated code.
* Contacts now don't just know the account name, but instead have
access to the newly created Account class. This means, we can
now move account related methods and data to the Account class
and can access them if we have a contact instance at hand.
* By introducing several PEP related classes it was possible to
cut the overall PEP code size in half (mostly due to
polymorphism): 523 insertions(+), 956 deletions(-)
* Adding a new PEP-Type can be done by creating a subclass and
implementing three methods. The only remaining cumbersome job is
due to RosterWindow which still requires that a new column is
added. All the drawing/updating should work out of the box
== What I encountered ==
Not much - just a lot of copy-pasted code. Removing the cruft was not
that funny. Often I had the impression that I was unifying code that
should have been unified from the beginning.
== What I learned ==
connection_handlers.py and connection.py can be simplified by using more
of what xmpppy gives to us: specific registration on stanzas per stanza,
type, namespace.
More tests would have been helpful. Doing my work was a shotgun surgery
because there where changes in many different places with almost no real
API. Having a local server and some highlevel roster tests saved me
several times. Looks like I have to write a few more highlevel tests
next time.
== Additional, bigger refactorings since 16.11.09 ==
* Asterix was able do drop a lot of Zeroconf code by introducing a
common Connection class and by dropping almost the complete
ConnectionBytestream implementation used by Zeroconf.
* Asterix re-refactored a few of my changes: Goal is that no
caller has to know whether an account is a local or normal one.
* Asterix dropped egg.trayicon. We now use the default GTK
statusicon
* I started an initial attempt to make dependencies of our
connection classes more explicit: In this particular case
ConnectionPEP now knows the objects on which it calls methods.
Before, it just assumed that "I will be subclassed and that the
subclass defines a few methods". First goal is to get rid of
false-positives in pylint and other statical checkers.
* Alexander updated all our docstrings to be consistent and
conforming to widely known coding standards.
* Thibaut started some cleanup work in the jingle area. (including
coding standards)
I hope I didn't miss anything.
Best Regards,
steve
More information about the Gajim-devel
mailing list