Convert large Accomplishments class to aspected "container" class

Bug #947288 reported by Duncan McGreggor on 2012-03-05
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu Accomplishments Daemon

Bug Description

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)

Duncan McGreggor (oubiwann) wrote :

One 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()

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

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.

description: updated
Duncan McGreggor (oubiwann) wrote :

Another option would be to use Twisted's multiservice approach. This would be appropriate for the remote stuff, and for anything that needs to pull from an outside data source (possibly even including configuration).

Of course, a mixture of each approach would be just fine as well.

Jono Bacon (jonobacon) on 2012-04-09
affects: ubuntu-accomplishments-system → ubuntu-accomplishments-daemon
Jono Bacon (jonobacon) wrote :

This has been open for a long time and I am not sure if this is much of a priority so closing the bug.

Jono Bacon (jonobacon) wrote :

If someone wants to work on this, feel free to reopen and assign it to yourself.

Changed in ubuntu-accomplishments-daemon:
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers