private class names variables should be preceded by _

Bug #1026749 reported by Matt Fischer
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu Accomplishments Daemon
Fix Released
Low
Matt Fischer

Bug Description

In python you can do a dir() on an object and use the results to write code even if you lack documentation. The pythonic way of marking something as private is to use _ in the name, for example _variable or _function_name. In the daemon, this was done for functions, perhaps not all of them, but not at all for variables. The _ in the name does not prevent someone from accessing the variable, just tells them "hey, you should be using a public interface, this one is not public". One example of a private variable is the script_queue variable in the Accomplishments class. Nobody should be messing with this except the class itself.

In the interest of keeping private variables private, I'd recommend the following changes:

1) Verify that all non-API functions are preceded by _.
2) Rename all private variables with an _ in the name.

Reference:
http://www.ibm.com/developerworks/library/l-pyint/index.html

Tags: bitesize
Changed in ubuntu-accomplishments-daemon:
status: New → Confirmed
importance: Undecided → Low
milestone: none → 0.3
Jono Bacon (jonobacon)
tags: added: bitesize
Matt Fischer (mfisch)
Changed in ubuntu-accomplishments-daemon:
assignee: nobody → Matt Fischer (mfisch)
Revision history for this message
Matt Fischer (mfisch) wrote :

Jono and I decided to only fix the functions, and there was only one incorrect. I fixed it and added some comments about places that need unit tests and fixed the typo in the spelling of list_opportunities()

Changed in ubuntu-accomplishments-daemon:
status: Confirmed → Fix Committed
Changed in ubuntu-accomplishments-daemon:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.