understanding someone else's program
denismfmcmahon at gmail.com
Fri Nov 15 18:41:22 CET 2013
On Fri, 15 Nov 2013 03:05:04 -0800, C. Ng wrote:
> Hi all,
> Please suggest how I can understand someone else's program where -
> documentation is sparse - in function A, there will be calls to function
> B, C, D.... and in those functions will be calls to functions R,S,T....
> and so on so forth... making it difficult to trace what happens to a
> certain variable
> Am using ERIC4 IDE.
You just have to work through it working out what each line does.
Start with the inputs and give them sensible names, after all you
presumably know where they come from and what they represent. Then you
can see what operations are being performed on the input data, and
presumably if you have enough knowledge in any relevant fields, may be
able to determine that, for example, when the input 'x' is actually a
temp in fahrenheit, then the math operation 'x=(x-32)*5/9' is really
"convert temp from fahrenheit to centigrade".
As you do this add relevant comments to the code. Eventually you'll have
code with sensible variable names and comments that hopefully describe
what it does.
Denis McMahon, denismfmcmahon at gmail.com
More information about the Python-list