Diagramming code

Discussion in 'Python' started by hamilton, Jul 16, 2012.

  1. hamilton

    hamilton Guest

    Is there any software to help understand python code ?

    Thanks

    hamilton
     
    hamilton, Jul 16, 2012
    #1
    1. Advertising

  2. hamilton

    Chris Rebert Guest

    On Sun, Jul 15, 2012 at 6:26 PM, hamilton <> 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!
     
    Chris Rebert, Jul 16, 2012
    #2
    1. Advertising

  3. hamilton

    hamilton Guest

    On 7/15/2012 7:38 PM, Chris Rebert wrote:
    > On Sun, Jul 15, 2012 at 6:26 PM, hamilton <> 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
     
    hamilton, Jul 16, 2012
    #3
  4. hamilton

    Chris Rebert Guest

    On Sun, Jul 15, 2012 at 6:57 PM, hamilton <> wrote:
    > On 7/15/2012 7:38 PM, Chris Rebert wrote:
    >>
    >> On Sun, Jul 15, 2012 at 6:26 PM, hamilton <> 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
     
    Chris Rebert, Jul 16, 2012
    #4
  5. 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
     
    Ulrich Eckhardt, Jul 16, 2012
    #5
  6. On Mon, Jul 16, 2012 at 3:58 AM, Ulrich Eckhardt
    <> 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
     
    Joel Goldstick, Jul 16, 2012
    #6
  7. hamilton

    Sells, Fred Guest

    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
     
    Sells, Fred, Jul 16, 2012
    #7
  8. On Sun, 15 Jul 2012 19:57:29 -0600, hamilton <>
    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
    HTTP://wlfraed.home.netcom.com/
     
    Dennis Lee Bieber, Jul 16, 2012
    #8
  9. hamilton

    hamilton Guest

    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
    >
     
    hamilton, Jul 16, 2012
    #9
  10. hamilton

    Miki Tebeka Guest

    Miki Tebeka, Jul 16, 2012
    #10
  11. 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..
     
    Andrea Crotti, Jul 16, 2012
    #11
  12. 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
     
    Andrew Cooper, Jul 16, 2012
    #12
  13. Chris Rebertæ–¼ 2012å¹´7月16日星期一UTC+8上åˆ9時38分53秒寫é“:
    > On Sun, Jul 15, 2012 at 6:26 PM, hamilton &lt;&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'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.
     
    88888 Dihedral, Jul 17, 2012
    #13
  14. Chris Rebertæ–¼ 2012å¹´7月16日星期一UTC+8上åˆ9時38分53秒寫é“:
    > On Sun, Jul 15, 2012 at 6:26 PM, hamilton &lt;&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'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.
     
    88888 Dihedral, Jul 17, 2012
    #14
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. UJ

    Diagramming a web site.

    UJ, Jun 3, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    398
    Joel Leong
    Jun 4, 2005
  2. Iain

    Sequence Diagramming

    Iain, Feb 13, 2006, in forum: Java
    Replies:
    4
    Views:
    457
  3. Replies:
    21
    Views:
    659
    Al Balmer
    Apr 14, 2006
  4. Replies:
    20
    Views:
    1,139
    Al Balmer
    Apr 14, 2006
  5. ixtahdoom

    Perl flow/code diagramming tools?

    ixtahdoom, Sep 9, 2004, in forum: Perl Misc
    Replies:
    1
    Views:
    140
    Mark Clements
    Sep 9, 2004
Loading...

Share This Page