Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #25376 > unrolled thread

Diagramming code

Started byhamilton <hamilton@nothere.com>
First post2012-07-15 19:26 -0600
Last post2012-07-16 23:24 +0100
Articles 14 — 10 participants

Back to article view | Back to comp.lang.python


Contents

  Diagramming code hamilton <hamilton@nothere.com> - 2012-07-15 19:26 -0600
    Re: Diagramming code Chris Rebert <clp2@rebertia.com> - 2012-07-15 18:38 -0700
      Re: Diagramming code hamilton <hamilton@nothere.com> - 2012-07-15 19:57 -0600
        Re: Diagramming code Chris Rebert <clp2@rebertia.com> - 2012-07-15 19:13 -0700
        Re: Diagramming code Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-07-16 09:58 +0200
          Re: Diagramming code Joel Goldstick <joel.goldstick@gmail.com> - 2012-07-16 05:00 -0400
        RE: Diagramming code "Sells, Fred" <fred.sells@adventistcare.org> - 2012-07-16 13:02 -0400
          Re: Diagramming code hamilton <hamilton@nothere.com> - 2012-07-16 12:36 -0600
        Re: Diagramming code Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-07-16 13:51 -0400
      Re: Diagramming code 88888 Dihedral <dihedral88888@googlemail.com> - 2012-07-17 07:11 -0700
      Re: Diagramming code 88888 Dihedral <dihedral88888@googlemail.com> - 2012-07-17 07:11 -0700
    Re: Diagramming code Miki Tebeka <miki.tebeka@gmail.com> - 2012-07-16 12:47 -0700
    Re: Diagramming code Andrea Crotti <andrea.crotti.0@gmail.com> - 2012-07-16 21:41 +0100
      Re: Diagramming code Andrew Cooper <amc96@cam.ac.uk> - 2012-07-16 23:24 +0100

#25376 — Diagramming code

Fromhamilton <hamilton@nothere.com>
Date2012-07-15 19:26 -0600
SubjectDiagramming code
Message-ID<jtvqkt$5ll$1@dont-email.me>
Is there any software to help understand python code ?

Thanks

hamilton

[toc] | [next] | [standalone]


#25377

FromChris Rebert <clp2@rebertia.com>
Date2012-07-15 18:38 -0700
Message-ID<mailman.2156.1342402742.4697.python-list@python.org>
In reply to#25376
On Sun, Jul 15, 2012 at 6:26 PM, hamilton <hamilton@nothere.com> wrote:
> Subject: Diagramming code
>
> Is there any software to help understand python code ?

What sort of diagrams? Control flow diagrams? Class diagrams? Sequence
diagrams? Module dependency diagrams? There are many different types
you could be referring to. Here's a relatively comprehensive list:
http://en.wikipedia.org/wiki/Unified_Modeling_Language#Diagrams_overview

Regards,
Chris
--
UML: Kill it with fire!

[toc] | [prev] | [next] | [standalone]


#25379

Fromhamilton <hamilton@nothere.com>
Date2012-07-15 19:57 -0600
Message-ID<jtvsec$d4b$1@dont-email.me>
In reply to#25377
On 7/15/2012 7:38 PM, Chris Rebert wrote:
> On Sun, Jul 15, 2012 at 6:26 PM, hamilton <hamilton@nothere.com> wrote:
>> Subject: Diagramming code
>>
>> Is there any software to help understand python code ?
>
> What sort of diagrams? Control flow diagrams? Class diagrams? Sequence
> diagrams? Module dependency diagrams? There are many different types
> you could be referring to. Here's a relatively comprehensive list:
> http://en.wikipedia.org/wiki/Unified_Modeling_Language#Diagrams_overview
>
> Regards,
> Chris
> --
> UML: Kill it with fire!
>

OK then, let me ask, how do you guys learn/understand large projects ?

hamilton

[toc] | [prev] | [next] | [standalone]


#25380

FromChris Rebert <clp2@rebertia.com>
Date2012-07-15 19:13 -0700
Message-ID<mailman.2158.1342404794.4697.python-list@python.org>
In reply to#25379
On Sun, Jul 15, 2012 at 6:57 PM, hamilton <hamilton@nothere.com> wrote:
> On 7/15/2012 7:38 PM, Chris Rebert wrote:
>>
>> On Sun, Jul 15, 2012 at 6:26 PM, hamilton <hamilton@nothere.com> wrote:
>>>
>>> Subject: Diagramming code
>>>
>>> Is there any software to help understand python code ?
>>
>> What sort of diagrams? Control flow diagrams? Class diagrams? Sequence
>> diagrams? Module dependency diagrams? There are many different types
>> you could be referring to. Here's a relatively comprehensive list:
>> http://en.wikipedia.org/wiki/Unified_Modeling_Language#Diagrams_overview
>>
>> Regards,
>> Chris
>> --
>> UML: Kill it with fire!
>
> OK then, let me ask, how do you guys learn/understand large projects ?

In case you're responding to my trailing semi-satirical comment, let
me clarify: I was remarking on UML specifically, not software-related
diagrams in general.

Cheers,
Chris

[toc] | [prev] | [next] | [standalone]


#25402

FromUlrich Eckhardt <ulrich.eckhardt@dominolaser.com>
Date2012-07-16 09:58 +0200
Message-ID<n6ucd9-srr.ln1@satorlaser.homedns.org>
In reply to#25379
Am 16.07.2012 03:57, schrieb hamilton:
> OK then, let me ask, how do you guys learn/understand large projects ?

1. Use the program. This gives you an idea what features are there and a 
bit how it could be structured.
2. Build the program, to see what is done to get the program running. 
This should give you an idea what pieces there are and where they are 
[from].
3. Read design documentation (which is too often outdated) which should 
give you an idea what the intention of the project's structure is.
4. Read the code documentation (which is hopefully more up to date). 
This should give you an idea about responsibilities within the code.
5. Read the code itself. This can also be done while single-stepping 
through it with a debugger, just to see it run.

Of course there are also secondary resources like developers' and users' 
mailinglists, websites, bugtrackers that provide information and help.

Sometimes, drawing a few diagrams from steps 3 and 4 to document 
relationships between things is helpful. IMHO having a text describing 
the relationships in prose is superior to that though. In particular a 
diagram can't describe the rationale for something, you need prose for that.

HTH & YMMV

Uli

[toc] | [prev] | [next] | [standalone]


#25403

FromJoel Goldstick <joel.goldstick@gmail.com>
Date2012-07-16 05:00 -0400
Message-ID<mailman.2165.1342429243.4697.python-list@python.org>
In reply to#25402
On Mon, Jul 16, 2012 at 3:58 AM, Ulrich Eckhardt
<ulrich.eckhardt@dominolaser.com> wrote:
> Am 16.07.2012 03:57, schrieb hamilton:
>
>> OK then, let me ask, how do you guys learn/understand large projects ?
>
>
> 1. Use the program. This gives you an idea what features are there and a bit
> how it could be structured.
> 2. Build the program, to see what is done to get the program running. This
> should give you an idea what pieces there are and where they are [from].
> 3. Read design documentation (which is too often outdated) which should give
> you an idea what the intention of the project's structure is.
> 4. Read the code documentation (which is hopefully more up to date). This
> should give you an idea about responsibilities within the code.
> 5. Read the code itself. This can also be done while single-stepping through
> it with a debugger, just to see it run.
>
> Of course there are also secondary resources like developers' and users'
> mailinglists, websites, bugtrackers that provide information and help.
>
> Sometimes, drawing a few diagrams from steps 3 and 4 to document
> relationships between things is helpful. IMHO having a text describing the
> relationships in prose is superior to that though. In particular a diagram
> can't describe the rationale for something, you need prose for that.
>
> HTH & YMMV
>
> Uli
> --
> http://mail.python.org/mailman/listinfo/python-list

Do you know about pydoc?  Its a great way to get a handle on your
modules.  It doesn't make diagrams, but a synopsis of what is in the
module.  It makes use of docstrings, for the module and each class and
function in the module.

-- 
Joel Goldstick

[toc] | [prev] | [next] | [standalone]


#25426

From"Sells, Fred" <fred.sells@adventistcare.org>
Date2012-07-16 13:02 -0400
Message-ID<mailman.2179.1342458201.4697.python-list@python.org>
In reply to#25379
You leave many relevant questions unanswered.

1. Is the original developer/team available or have you been left with
the code and little or no doc's?

2. How big is big in terms of the number of files/modules in the
project?  

3. Is there a reasonable structure to the project in terms of
directories and a meaningful hierarchy

4. Does the project currently work and you just have to maintain/enhance
it or was it "abandoned" by the original team in an unknown state and
you have to save a sinking ship?

5. Are you an experienced Python programmer or a beginner.

6. Is the original code "pythonic" (i.e. clean and simple with brief,
well organized methods) or do you have functions over 50 lines of code
with multiple nested control statements and meaningless variable names?

7. Is there any documentation that defines what it should do and how it
should do it.  i.e. how do you know when it's working?

These issues are not really Python specific, but if you've been given a
"broken" project that has 200 poorly organized modules and little or no
documentation and no access to the original team, a good first step
would be to update your resume ;)

OK then, let me ask, how do you guys learn/understand large projects ?

hamilton

--
http://mail.python.org/mailman/listinfo/python-list

[toc] | [prev] | [next] | [standalone]


#25434

Fromhamilton <hamilton@nothere.com>
Date2012-07-16 12:36 -0600
Message-ID<ju1mv5$3hq$1@dont-email.me>
In reply to#25426
Thank you Fred.

I am new to python and am reviewing code I find online.

Some projects do have docs that spell out what its doing,
but many projects that I have download have just the code.

I have my own personal style to decypher C and C++ code.

But python is still foreign to me.

hamilton


On 7/16/2012 11:02 AM, Sells, Fred wrote:
> You leave many relevant questions unanswered.
>
> 1. Is the original developer/team available or have you been left with
> the code and little or no doc's?
>
> 2. How big is big in terms of the number of files/modules in the
> project?
>
> 3. Is there a reasonable structure to the project in terms of
> directories and a meaningful hierarchy
>
> 4. Does the project currently work and you just have to maintain/enhance
> it or was it "abandoned" by the original team in an unknown state and
> you have to save a sinking ship?
>
> 5. Are you an experienced Python programmer or a beginner.
>
> 6. Is the original code "pythonic" (i.e. clean and simple with brief,
> well organized methods) or do you have functions over 50 lines of code
> with multiple nested control statements and meaningless variable names?
>
> 7. Is there any documentation that defines what it should do and how it
> should do it.  i.e. how do you know when it's working?
>
> These issues are not really Python specific, but if you've been given a
> "broken" project that has 200 poorly organized modules and little or no
> documentation and no access to the original team, a good first step
> would be to update your resume ;)
>
> OK then, let me ask, how do you guys learn/understand large projects ?
>
> hamilton
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

[toc] | [prev] | [next] | [standalone]


#25432

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2012-07-16 13:51 -0400
Message-ID<mailman.2184.1342461074.4697.python-list@python.org>
In reply to#25379
On Sun, 15 Jul 2012 19:57:29 -0600, hamilton <hamilton@nothere.com>
declaimed the following in gmane.comp.python.general:

> 
> OK then, let me ask, how do you guys learn/understand large projects ?
>
	First -- by divorcing them from the implementation language...

	Historically... 

	Graphically from small to large: flow-charts,
Nassi-Schneiderman/Chapin charts, N-squared charts, UML diagrams

	Textually: the realm of system analysis (though my college textbook
on such was somewhat ad-hoc, being quite focused on "reproducing for the
computer user what was being done on paper" [making screen forms look
like paper forms, etc.]), requirements analysis, UML Use Cases...

	If joining a project that is already well underway, one reads the
already generated requirements specification/Use Case documents (these
define what the project does and how it interacts with the world). If
UML diagrams exist, one can then start looking at class diagrams to
learn the components of the project, and associations between classes.
Eventually one gets to convert the classes from UML generalizations into
an actualized implementation (Python, Ada, C++, Fortran 95... wherein
one may encounter minor idiosyncracies that make some UML notation
difficult to implement).

	If one is just starting a project, then modern systems/requirements
analysis techniques (these days, probably subsumed under
"object-oriented analysis" [OOA]) should be undertaken to derive the
requirements/use cases. Then followed by software design of modules and
interfaces (or, currently, "object-oriented design" [OOD] to develop the
classes, attributes, and associations) to be implemented. {OOA and OOD
together appear as OOAD}.
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [next] | [standalone]


#25503

From88888 Dihedral <dihedral88888@googlemail.com>
Date2012-07-17 07:11 -0700
Message-ID<mailman.2222.1342534318.4697.python-list@python.org>
In reply to#25377
Chris Rebert於 2012年7月16日星期一UTC+8上午9時38分53秒寫道:
> On Sun, Jul 15, 2012 at 6:26 PM, hamilton &lt;hamilton@nothere.com&gt; wrote:
> &gt; Subject: Diagramming code
> &gt;
> &gt; Is there any software to help understand python code ?
> 
> What sort of diagrams? Control flow diagrams? Class diagrams? Sequence
> diagrams? Module dependency diagrams? There are many different types
> you could be referring to. Here&#39;s a relatively comprehensive list:
> http://en.wikipedia.org/wiki/Unified_Modeling_Language#Diagrams_overview
> 
> Regards,
> Chris
> --
> UML: Kill it with fire!

OK, I'll classify OOP by (1) properties of instances of declared classes must be fixed such as those in C++ (2) An interpreter could be embedded in the run time for an object to evolve through time to accquire properties.


If the robot age was to be comming, what can we do now?

 I think learning python is the high school 
does help a lot for the United States in the future.

[toc] | [prev] | [next] | [standalone]


#25507

From88888 Dihedral <dihedral88888@googlemail.com>
Date2012-07-17 07:11 -0700
Message-ID<b774c925-38e6-4ebc-b5f7-0c505da8d502@googlegroups.com>
In reply to#25377
Chris Rebert於 2012年7月16日星期一UTC+8上午9時38分53秒寫道:
> On Sun, Jul 15, 2012 at 6:26 PM, hamilton &lt;hamilton@nothere.com&gt; wrote:
> &gt; Subject: Diagramming code
> &gt;
> &gt; Is there any software to help understand python code ?
> 
> What sort of diagrams? Control flow diagrams? Class diagrams? Sequence
> diagrams? Module dependency diagrams? There are many different types
> you could be referring to. Here&#39;s a relatively comprehensive list:
> http://en.wikipedia.org/wiki/Unified_Modeling_Language#Diagrams_overview
> 
> Regards,
> Chris
> --
> UML: Kill it with fire!

OK, I'll classify OOP by (1) properties of instances of declared classes must be fixed such as those in C++ (2) An interpreter could be embedded in the run time for an object to evolve through time to accquire properties.


If the robot age was to be comming, what can we do now?

 I think learning python is the high school 
does help a lot for the United States in the future.

[toc] | [prev] | [next] | [standalone]


#25435

FromMiki Tebeka <miki.tebeka@gmail.com>
Date2012-07-16 12:47 -0700
Message-ID<11eb95a3-f358-4f57-89f0-ba72abf3cb01@googlegroups.com>
In reply to#25376
> Is there any software to help understand python code ?
For module dependency you can try http://furius.ca/snakefood/

[toc] | [prev] | [next] | [standalone]


#25438

FromAndrea Crotti <andrea.crotti.0@gmail.com>
Date2012-07-16 21:41 +0100
Message-ID<mailman.2188.1342471334.4697.python-list@python.org>
In reply to#25376
On 07/16/2012 02:26 AM, hamilton wrote:
> Is there any software to help understand python code ?
>
> Thanks
>
> hamilton

Sometimes to get some nice graphs I use gprof2dot 
(http://code.google.com/p/jrfonseca/wiki/Gprof2Dot)
or doxygen (http://www.stack.nl/~dimitri/doxygen/)

gprof2dot analyses the output of the profiling that you get running the 
code through the python profiler,
doing for example:

python -m cProfile -o $STATS $FNAME $@
$GPROF2DOT -f pstats $STATS | dot -T$TYPE -o $OUT

doxygen is more useful for C++ but it's also able to infer a few things 
(without running) from a python project..

[toc] | [prev] | [next] | [standalone]


#25445

FromAndrew Cooper <amc96@cam.ac.uk>
Date2012-07-16 23:24 +0100
Message-ID<bw0Nr.6447$114.5073@fx26.am4>
In reply to#25438
On 16/07/2012 21:41, Andrea Crotti wrote:
> On 07/16/2012 02:26 AM, hamilton wrote:
>> Is there any software to help understand python code ?
>>
>> Thanks
>>
>> hamilton
> 
> Sometimes to get some nice graphs I use gprof2dot
> (http://code.google.com/p/jrfonseca/wiki/Gprof2Dot)
> or doxygen (http://www.stack.nl/~dimitri/doxygen/)
> 
> gprof2dot analyses the output of the profiling that you get running the
> code through the python profiler,
> doing for example:
> 
> python -m cProfile -o $STATS $FNAME $@
> $GPROF2DOT -f pstats $STATS | dot -T$TYPE -o $OUT
> 
> doxygen is more useful for C++ but it's also able to infer a few things
> (without running) from a python project..

+1 for doxygen.

Combined with http://code.foosel.org/doxypy , it is a fully featured
solution.  I use it for all my projects, python and otherwise.

~Andrew

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web