Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tune
apt info
reporting, esp. for "installed version"
...and, I realize I've muddled and confused things. The main data tables need clear separation, "package names and version available on server" and "what is actually locally installed". The old functions actually maintained this better before I started messing with them. (In my defense, they were horribly opaque tho'.) For instance I grew the idea that `apt ball` reconstructed the version name from the currently available archive filename on the server. Yes, get_ball() constructs from the filename, but not from the filename in setup.ini, it's actually from the name in installed.db -- a crucial difference! TODO: rescue good parts of old functions, clearly separate local/server info, dump overlapping dict records.
- Loading branch information
4b9190f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As being relatively new to apt programming and English not my native language, I often thought about the structure of apt and the names of functions and variables.
Difficult to see through is the length of code, so I would suggest to split it in functional or logical parts. I saw this in different github projects, that multiple python files exist, but only one complete file was the output for installing - never tried out, if a ide/tool supports such things? On the other hand, importing them as modules shouldn't be a problem either.
I really don't like all the globals, because one can never be sure if and where they are initialized, even you don't see they are global. And I like to have a main(argv) function and a short global section.
One way out of this is using classes, as they have separated name spaces and we could name similar variables equally - same with separated modules.
My proposal:
"apt" is the name of the program, handling the commands, checking options, environment: it's our User Interface.
"setup" describes the superior thing of apt. It is the connection between server and local stuff. As a command ('setup') it initialises the installation. It knows, which setup files will be stored and where to find them ('setup_rc: rc=resources: wrong word right action?').
"installation" describes the output of apt well, as the local part of setup, it deals with the local install (as a command) of packages, does the post_install, reports errors and success of installed packages
"repository" is often used for what osgeo4w download server is, it is the availability of "ressources", it has mirrors, several trees ("architectures") and holds downloadable setup files and packages
"packages", I liked to encapsulate them, containing the metadata and information about the 'content'. They could have a server and a local "status", mainly a version and a installed flag.
It's not mandatory to realize a class structure, but, as you said, words should be clear and intuitiv. As I wrote, its a proposal, hoping to give some impulse.
4b9190f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your thoughts and perspective are very welcome. I tend to wordy and flowery language, which I imagine makes me difficult to understand sometimes, coming from another mother tongue. Please don't hesitate to let me know when I'm confusing more than illuminating.
Doing something about the global "pollution" has been a main drivers for all the changes I've made in the last year or so. I've tackled it in very small pieces, striving to maintain an always functional program. This comes after more ambitious attempts to start from the top down didn't go very well (see wildlands folder). Perhaps better said as: I learned a whole lot, but didn't emerge on the other side with much working and reusable code!
Thinking about how to divide
I see the major categories as:
Naming the user interaction category/class/module "apt" makes sense to me. Not sure about the others.
Of these user interaction which is most broken. I've sampled a number of alternative parameter/argument approaches and am leaning strongly towards Click. My loose game plan has been to make all the top level commands (those reported by
apt help
) bug free, or at least reliable most of the time, issue a stable release, and then start a "proper argument handling" branch. However after last night I'm thinking Clarify data model muddle (#35) might be more important. Or maybe they're just different facets of the same rough gem.Either way getting to a stable release is my next immediate goal (without significant restructuring that will delay even longer).
Modules vs Classes: I've used classes once or twice but don't understand them very well, so tend to avoid. I don't have a feel for when a class should be chosen over a module or vice versa. I'm quite willing to explore using classes, but likely wouldn't make a good architect for building them at this stage in my learning. (In other words: make a fork, I'll try and eat with it!)
4b9190f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
that would be a big branch :-)
4b9190f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
however, I started testing a first oo-version, began it some weeks ago...