reading other peoples code

Discussion in 'C++' started by vfunc@talktalk.net, Aug 4, 2006.

  1. Guest

    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.
     
    , Aug 4, 2006
    #1
    1. Advertising

  2. wrote:
    > 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
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Aug 4, 2006
    #2
    1. Advertising

  3. ScriptDevil Guest

    wrote:

    > 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
     
    ScriptDevil, Aug 4, 2006
    #3
  4. ScriptDevil wrote:
    > wrote:
    >
    >> 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.


    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
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Aug 4, 2006
    #4
  5. Phlip Guest

    vfunc wrote:

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

    news:comp.software-eng is also a good hit.

    --
    Phlip
    http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
     
    Phlip, Aug 4, 2006
    #5
  6. Phlip Guest

    ScriptDevil wrote:

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

    --
    Phlip
    http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
     
    Phlip, Aug 4, 2006
    #6
  7. Guest

    Victor Bazarov wrote:
    > > [.. good advice on recursive exploration of source code snipped ..]

    >
    > No disagreement there.
    >


    ScriptDevil wrote:
    > 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.
     
    , Aug 4, 2006
    #7
  8. Noah Roberts Guest

    wrote:
    > 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.
     
    Noah Roberts, Aug 4, 2006
    #8
  9. wrote:
    > Victor Bazarov wrote:
    >>> [.. good advice on recursive exploration of source code snipped ..]

    >>
    >> No disagreement there.
    >>

    >
    > ScriptDevil wrote:
    >> 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
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Aug 4, 2006
    #9
  10. On 4 Aug 2006 04:19:24 -0700, ""
    <> wrote:
    >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
     
    Roland Pibinger, Aug 4, 2006
    #10
  11. Guest

    Noah Roberts wrote:
    > wrote:
    > > 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.


    I've done that before (not with C++), but I did not know that was what
    it is called.
     
    , Aug 4, 2006
    #11
    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. Dexter
    Replies:
    3
    Views:
    337
    Ben Strackany
    Nov 30, 2004
  2. Replies:
    0
    Views:
    496
  3. Replies:
    0
    Views:
    790
  4. brad
    Replies:
    15
    Views:
    450
    Chris Mellon
    Oct 11, 2007
  5. Randy Hudson

    My web pages always look different on other peoples computers.

    Randy Hudson, Dec 28, 2003, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    155
    Alvin Bruney
    Dec 28, 2003
Loading...

Share This Page