Re: Diagramming code
Chris Rebert於 2012年7月16日星期一UTC+8上午9時38分53秒寫道: On Sun, Jul 15, 2012 at 6:26 PM, hamilton lt;hamil...@nothere.comgt; 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. -- http://mail.python.org/mailman/listinfo/python-list
Re: Diagramming code
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
Re: Diagramming code
On Mon, Jul 16, 2012 at 3:58 AM, Ulrich Eckhardt ulrich.eckha...@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 -- http://mail.python.org/mailman/listinfo/python-list
RE: Diagramming code
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Diagramming code
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Diagramming code
Is there any software to help understand python code ? For module dependency you can try http://furius.ca/snakefood/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Diagramming code
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.. -- http://mail.python.org/mailman/listinfo/python-list
Re: Diagramming code
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Diagramming code
On Sun, Jul 15, 2012 at 6:26 PM, hamilton hamil...@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! -- http://mail.python.org/mailman/listinfo/python-list
Re: Diagramming code
On 7/15/2012 7:38 PM, Chris Rebert wrote: On Sun, Jul 15, 2012 at 6:26 PM, hamilton hamil...@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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Diagramming code
On Sun, Jul 15, 2012 at 6:57 PM, hamilton hamil...@nothere.com wrote: On 7/15/2012 7:38 PM, Chris Rebert wrote: On Sun, Jul 15, 2012 at 6:26 PM, hamilton hamil...@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 -- http://mail.python.org/mailman/listinfo/python-list