Understanding other people's code
cmpython at gmail.com
Mon Jul 15 21:13:14 CEST 2013
On Monday, July 15, 2013 6:02:30 AM UTC-4, Azureaus wrote:
> To be fair to who programmed it, most functions are commented and I can't
> complain about the messiness of the code, It's actually very tidy. (I suppose
> Python forcing it's formatting is another reason it's an easily readable
> language!) Luckily not blanked import * were used otherwise I really would be
> up the creek without a paddle.
Oh, good! OK, so then what you can think in terms of, in terms of a simple strategy for getting clear without any fancy tools:
Learn what each module is for. In my own application programming, I don't just put random classes and functions in any old module--the modules have some order to them. So, for example, one module may represent one panel in the application, or all the database stuff, or all the graphing stuff, or some other set of logic, or whatever. One might be the main GUI frame. Etc. So I'd get a notebook or file and make notes for yourself about what each module is for, and the name. Even tack a piece of paper above your workstation with the module names and a one line note about what they do, like:
Map_panel: Displays a panel with the map of the city, with a few buttons.
Dbases: Has all utility functions relevant to the database.
Utils: Has a collection of utility functions to format time, i18n, etc.
Now, there's a cheat sheet. So, if you come across a line in your code like:
pretty_time = Utils.GetPrettyTime(datetime)
You can quickly look at Utils module and read more about that function.
Does this approach make sense to at least clear the cobwebs?
More information about the Python-list