reading other peoples code

V

vfunc

OK, after reading some C++ books and writing some programs that cover
the core, where do I go from there, to say be able to read some open
source code ? How do you unravel other peoples code when you are not
familiar with the calls, style etc ? Are there any tools for analysing
/ displaying a program structure ? Are there any forums that discuss
such topics, because I guess this is not really the right group.
 
V

Victor Bazarov

OK, after reading some C++ books and writing some programs that cover
the core, where do I go from there, to say be able to read some open
source code ?

Not enough open source projects for you on the web? Have you actually
tried, like, *googling* for them?
How do you unravel other peoples code when you are not
familiar with the calls, style etc ?

You get familiar while reading. But often, and hopefully you will see
that relatively soon, a program is a program, style doesn't really matter.
Are there any tools for
analysing / displaying a program structure ?

There probably are. *I* couldn't find even one that would do a decent
job of it. Of course, *I* just don't have time to look for them. While
working on the same project for some time one stops appreciating those tools
because one learns the structure of the project and those tools are not
needed, most often.
Are there any forums
that discuss such topics, because I guess this is not really the
right group.

What topics are those? Style? Tools? Where to find open source projects?

V
 
S

ScriptDevil

OK, after reading some C++ books and writing some programs that cover
the core, where do I go from there, to say be able to read some open
source code ? How do you unravel other peoples code when you are not
familiar with the calls, style etc ? Are there any tools for analysing
/ displaying a program structure ? Are there any forums that discuss
such topics, because I guess this is not really the right group.

any group can discuss any topic AS LONG AS IT IS BENEFICIAL IMHO.

Start with simple progs like a small console based app.( i started for
python with curphoo)
As far as where to start reading the program is concerned.. This is a
tougie.
I myself had the doubt for ages and finally settled with one i got in
my distro's forum. it said start with the cpp file containing main().
Cos there can only be one main() in the entire app.Read the program If
u encounter a new method, Read the header file /library / another C++
file( mostly having the same name as the header where the func is
defined ) where the function is defined. Forget the other functions.
Read like this and soon u will learn most of the calls of the prog.
Then read the remaining headers to glimpse through the functions
declared there.
As i like to say it
Reading a program must be Recursive
All the best
 
V

Victor Bazarov

ScriptDevil said:
any group can discuss any topic AS LONG AS IT IS BENEFICIAL IMHO.

First of all, please don't SHOUT. Find a different way of emphasising.

Second, the topicality defines *what is beneficial*. Trying to separate
those two things will wreak havoc in any newsgroup, and Usenet in general,
and therefore is a BAD IDEA(tm). So, if it's not topical it's not by any
means beneficial, by definition.

That is not to say that C++ style is off-topic. It's not to say that
naming the tools that allow you to understand code better is off-topic.
Just don't ask how to use them, because that is off-topic.

As to where to find open source projects to read... Come on!
[.. good advice on recursive exploration of source code snipped ..]

No disagreement there.

V
 
P

Phlip

vfunc said:
OK, after reading some C++ books and writing some programs that cover
the core, where do I go from there, to say be able to read some open
source code ?

Run Doxygen, and convert the code into a web site.
How do you unravel other peoples code when you are not
familiar with the calls, style etc ?

Put the code into a "sandbox", which is a copy you will not publish, and try
to add a feature to it.
Are there any tools for analysing
/ displaying a program structure ?

Read /Working Effectively with Legacy Code/, by Mike Feathers (which wins
the award for the book I cite most frequently on USENET!), and then add unit
tests to the code.

No lie. Doing that will force you to represent the program's structure,
because test cases must build and assemble its objects.

(Better, download a C++ program _with_ unit tests, and make this step
simpler!)
Are there any forums that discuss
such topics, because I guess this is not really the right group.

This is a good group for it, because everyone here (who is anyone) has done
this for C++.

is also a good hit.
 
P

Phlip

ScriptDevil said:
any group can discuss any topic AS LONG AS IT IS BENEFICIAL IMHO.

Replace "IMHO", with "to the original poster".

Posting a hard technical question (my call to Foo(bar) crashed!) on the
narrowest possible newsgroup, for a good answer...
 
V

vfunc

Victor said:
[.. good advice on recursive exploration of source code snipped ..]

No disagreement there.
As i like to say it
Reading a program must be Recursive
All the best

OK, main is the root of the tree, but could you be be more specific ?
I am guessing you mean some kind of layered search more like in-order,
pre-order would tend to get you in deep too quickly.
What about taking notes ?
One thing I do know is that you can't assume that a function always
does what it is title suggests.
Thanks.
 
N

Noah Roberts

OK, after reading some C++ books and writing some programs that cover
the core, where do I go from there, to say be able to read some open
source code ? How do you unravel other peoples code when you are not
familiar with the calls, style etc ? Are there any tools for analysing
/ displaying a program structure ? Are there any forums that discuss
such topics, because I guess this is not really the right group.

Try a "Scratch Refactoring" session.
 
V

Victor Bazarov

Victor said:
[.. good advice on recursive exploration of source code snipped ..]

No disagreement there.
As i like to say it
Reading a program must be Recursive
All the best

OK, main is the root of the tree, but could you be be more specific ?

It actually is not necessarily the root. Static objects are created before
'main' is called and destroyed after 'main' has finished.
I am guessing you mean some kind of layered search more like in-order,
pre-order would tend to get you in deep too quickly.

Search? I don't know. Probably. I always associate "search" with the
process when you know what you look for. This is rather REsearch.
What about taking notes ?

Take them. They're yours. Use them wisely.
One thing I do know is that you can't assume that a function always
does what it is title suggests.

That's true. The other thing is to read the comments (however scarce
they might be). I sometimes fall into "I can read the code, who cares
what the comments say" mode, but it's less productive. Skip the code
and read the comments first. Perhaps they actually explain what the
intentions were...

Good luck!

V
 
R

Roland Pibinger

OK, after reading some C++ books and writing some programs that cover
the core, where do I go from there, to say be able to read some open
source code ? How do you unravel other peoples code when you are not
familiar with the calls, style etc ? Are there any tools for analysing
/ displaying a program structure ? Are there any forums that discuss
such topics, because I guess this is not really the right group.

'Code Reading' from Diomidis Spinellis may be interesting to you:
http://www.spinellis.gr/codereading/
Examples are rather in C than in C++.

Best wishes,
Roland Pibinger
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top