Tuesday, 10 November 2009

API unification

I am working on last bits of new Kadu API. Works that needs to be done can be summarized in 3 points:

  1. move all important classes to base/shared/details model
  2. extract as much as possible from base/shared/details model to common base classes
  3. remove Buddy::contact(Account) method (or remove unnecessary uses of it)
Base/Shared/Details model

This is the improved structure of our main classes (Buddy, Contact, Identity, Avatar...). Base class (named simply Contact) is responsible to give access to object data. Every copy of such object contains pointer to the same Shared class (like ContactShared) contains data, can read and store it (it is always UuidStorableObject). Thanks to that we don't need to worry about working on copy of object instead of original one (the only class that knows about Shared class is the Base class).

Details classes allowed us to switch from IS-A to HAS-A relation (now GaduContact does not inherits Contact, just GaduContactDetails inherits ContactDetails and ContactShared object contains one of ContactDetails objects). This allows us to load all accounts/buddies and contacts at once and only populate details fields when protocol module is loaded. So situation where some object exists only in configuration and not in running program is not possible now. You can read history of such contact now ;)

A lot of code for these classes is duplicated: it needs extraction to template classes, and it will be done after Contact is ported to this new model.

BTW: I've renamed Contact to Buddy and ContactAccountData to Contact, so the names do make sense now ;) It was very problematically but I think that it was worth the effort.

Removing Buddy::contact(Account) method

This method assumes that a Buddy can have only one Contact for one Account. We don't like this assumption (someone can have a friend with 10 Jabber accounts, so why limit connections to only one?). After this function is removed (or its usage reduced as much as possible) this will be possible. We also need to remove functions with Account/Buddy pairs and replace that with Contact. It will also make moving Contacts between Buddies simpler (and merging and splitting Buddies too).

0.6.6 alpha0 - soft API freeze (or I will not mess so much anymore)

These are the last three things I want to do before soft API freeze. Be prepared to testing first alpha release ;)

No comments:

Post a Comment