Diagramming code

C

Chris Rebert

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
 
U

Ulrich Eckhardt

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
 
J

Joel Goldstick

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

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.
 
S

Sells, Fred

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
 
D

Dennis Lee Bieber

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}.
 
H

hamilton

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
 
A

Andrea Crotti

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..
 
A

Andrew Cooper

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
 
8

88888 Dihedral

Chris Rebertæ–¼ 2012å¹´7月16日星期一UTC+8上åˆ9時38分53秒寫é“:
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

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.
 
8

88888 Dihedral

Chris Rebertæ–¼ 2012å¹´7月16日星期一UTC+8上åˆ9時38分53秒寫é“:
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

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top