On 2014-04-23 21:57, tim.thel...@gmail.com wrote:
Hello,
I am currently writting a program called subuser(subuser.org), which
is written as classically imperative code. Subuser is, essentially,
a package manager. It installs and updates programs from
repositories.
I have a set of source files
https://github.com/subuser-security/subuser/tree/master/logic/subuserCommands/subuserlib
which have functions in them. Each function does something to a
program, it identifies the program by the programs name. For
example, I have an installProgram function defined as such:
def installProgram(programName, useCache):
Now I've run into a flaw in this model. There are certain situations
where a "programName" is not a unique identifier. It is possible for
two repositories to each have a program with the same name.
Obviously, I could go through my code and replace all use of the
string "programName" with a tuple of (programName, repository). Or I
could define a new class with two attributes: programName and
repository, and pass such a simple object arround, or pass a
dictionary. However, I think this would be better solved by moving
fully to an OOP model. That is, I would have a SubuserProgram class
which had methods such as "install", "describe", "isInstalled"...
[snip]
Could you make the program name unique just by combining it with the
repository name in a single string?
--
https://mail.python.org/mailman/listinfo/python-list