Convert large Accomplishments class to aspected "container" class
Bug #947288 reported by
Duncan McGreggor
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Ubuntu Accomplishments Daemon |
Won't Fix
|
Undecided
|
Unassigned |
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)
affects: | ubuntu-accomplishments-system → ubuntu-accomplishments-daemon |
To post a comment you must log in.
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()
...
etc.
Then, for the AccomplishmentS ervice 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.