Comment 0 for bug 947288

Revision history for this message
Duncan McGreggor (oubiwann) wrote :

The daemon code has a very large class called Accomplishments. It performs the following sorts of tasks:
 * image manipulation
 * configuration management
 * cache dir setup
 * accomplishment management
 * trophy file utilities
 * UbuntuOne interaction
 * one dbus method (that could arguable be moved into the dbusapi code, depending upon how one went about that)

Probably the best way to do this is isolate the functionality in each of the above groups into separate classes (e.g., ImageAPI, ConfigAPI, CacheAPI, AccomplishmentAPI, RemoteAPI, DBUSAPI, etc., maybe with generally useful code going in a parent class, called API).

Then, an overarching class can be created that has aspects (attribute) which are the instantiated API classes. For example:

class SomeGoodName(object):
  def __init__(self, ...):
    self.image = ImageAPI()
    self.config = CongfigAPI()
    self.cache = CacheAPI()
    ...
    etc.

Then, for the AccomplishmentService class to reference, e.g., a RemoteAPI method, it would do something along the lines of:

  self.ad.remote.verifyU1Account(...)

This will keep things more organized, easier to read, easier to maintain (folks will know where to put new functionality and keep things clean, as opposed to rapid crustification), etc.