Understanding large C++ programs

Discussion in 'C++' started by sasquatch, Oct 18, 2006.

  1. sasquatch

    sasquatch Guest

    X-No-Archive:

    Are there any good books that provide tips about how to understand and
    "play with" large C++ programs? It seems like a very important skill,
    and yet its hardly taught in the universities. Basic programming skills
    and knowledge of language constructs don't seem enough for
    understanding larger programs.
    sasquatch, Oct 18, 2006
    #1
    1. Advertising

  2. sasquatch wrote:
    > Are there any good books that provide tips about how to understand and
    > "play with" large C++ programs?


    Actually, it doesn't matter in what language those programs are written.
    Understanding large systems requires a different approach than writing
    code. That's why in most cases it's a "software engineering" problem
    and not a "programming" one.

    > It seems like a very important skill,


    Yes. And it's not a simple skill to teach. Knowing how to lay
    bricks isn't enough to build a house. However, you can learn to
    build houses without ever learning to lay bricks.

    > and yet its hardly taught in the universities.


    I'll take your word for it.

    > Basic programming
    > skills and knowledge of language constructs don't seem enough for
    > understanding larger programs.


    They aren't.

    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, Oct 18, 2006
    #2
    1. Advertising

  3. sasquatch

    Jim Langston Guest

    "sasquatch" <> wrote in message
    news:...
    > X-No-Archive:
    >
    > Are there any good books that provide tips about how to understand and
    > "play with" large C++ programs? It seems like a very important skill,
    > and yet its hardly taught in the universities. Basic programming skills
    > and knowledge of language constructs don't seem enough for
    > understanding larger programs.


    Some large systems are easier to learn than others. It's not something that
    easily taught, as sometimes even understanding a small program can be a pain
    depending on how it's written.

    Generally when I want to understand a program I will load it up in my
    favorite editor and start putting it into a format I'm familiar with. This
    does two things, it makes it easier for me to read, but it also makes me
    familiar with the code. I will not save the editing I do, but it just helps
    me becuase I have to go through the entire code. I don't know if others do
    this. If, on the other hand, code is already in a format that's easy for me
    to read then I'm happy.

    One of the things I do there is change stupid variable names to ones that
    make sense if they didn't do that. Oh, they used ii for number of steps,
    let me change that to NumOfSteps with search and replace if I can, etc..

    Usually by the time I"m done with that I understand the code. If not, then
    I need to start looking at it closer.

    Some programs are just a joy to read, withi good structured code with
    logical variable names I find I can read it as easy as a book, if not
    easier.

    There was one program I was working on, however, modifying that even after 3
    months of working on it I still didn't understand that code fully, it was so
    horribly written (C code, not C++).

    I really don't know what to tell you.
    Jim Langston, Oct 18, 2006
    #3
  4. sasquatch

    Noah Roberts Guest

    sasquatch wrote:
    > X-No-Archive:
    >
    > Are there any good books that provide tips about how to understand and
    > "play with" large C++ programs? It seems like a very important skill,
    > and yet its hardly taught in the universities. Basic programming skills
    > and knowledge of language constructs don't seem enough for
    > understanding larger programs.


    There is no real way to understand larger programs. The problem is too
    large for most human brains. You can understand the big picture if the
    design is good. You can understand particular parts very well and how
    they plug into the bigger design. Sometimes you know different parts
    than you do at other times. I can only wrap my head around a few
    thousand lines of code at once. This is why I use reminders
    (descriptive names and small functions) and constructs that are not
    easily used incorrectly.

    The real issue is being able to follow and decipher localized areas of
    code and create an understanding of the area you are working on. Some
    designs are easier than others in this regard; for instance, small
    functions are always easier to understand than long ones. One trick is
    to do what is called a scratch refactor...that is, go into the code and
    do some cleaning wherever you see a need, when you are done you throw
    it away and start over with a clearer idea of what is needed. It is
    described better in Working Effectively with Legacy Code by Michael
    Feathers...or you can google it.

    Speaking of google, some good keywords are "refactoring" and "design
    patterns".

    Most Universities teach you next to nothing that you need in the
    workforce. This type of thing is only recieved through experience.
    There are plenty of OS projects you can play with, some are VERY large.
    You can always download the source and try to understand it even if
    they don't let you submit changes.
    Noah Roberts, Oct 18, 2006
    #4
  5. sasquatch schrieb:
    > X-No-Archive:
    >
    > Are there any good books that provide tips about how to understand and
    > "play with" large C++ programs? It seems like a very important skill,
    > and yet its hardly taught in the universities.


    Your university does not teach software engineering? Bad one ...
    =?ISO-8859-1?Q?Jens_M=FCller?=, Oct 19, 2006
    #5
  6. sasquatch

    Guest

    sasquatch wrote:
    > X-No-Archive:
    >
    > Are there any good books that provide tips about how to understand and
    > "play with" large C++ programs? It seems like a very important skill,
    > and yet its hardly taught in the universities. Basic programming skills
    > and knowledge of language constructs don't seem enough for
    > understanding larger programs.

    Try "Large-Scale C++ Software Design", by John Lakos.
    , Oct 19, 2006
    #6
  7. sasquatch

    sasquatch Guest

    Jens Müller wrote:
    > sasquatch schrieb:
    > > X-No-Archive:
    > >
    > > Are there any good books that provide tips about how to understand and
    > > "play with" large C++ programs? It seems like a very important skill,
    > > and yet its hardly taught in the universities.

    >
    > Your university does not teach software engineering? Bad one ...


    There is a difference between building software and understanding
    legacy systems. The first is taught in software engineering classes,
    the latter is not.
    sasquatch, Oct 19, 2006
    #7
  8. sasquatch

    ralph Guest

    sasquatch schrieb:

    > X-No-Archive:
    >
    > Are there any good books that provide tips about how to understand and
    > "play with" large C++ programs?


    Spinellis: Code Reading

    hth
    ralpe
    ralph, Oct 19, 2006
    #8
  9. Jim Langston wrote:
    > "sasquatch" <> wrote in message


    > > Are there any good books that provide tips about how to understand and
    > > "play with" large C++ programs? It seems like a very important skill,
    > > and yet its hardly taught in the universities. Basic programming skills
    > > and knowledge of language constructs don't seem enough for
    > > understanding larger programs.


    <snip>

    > Generally when I want to understand a program I will load it up in my
    > favorite editor and start putting it into a format I'm familiar with. This
    > does two things, it makes it easier for me to read, but it also makes me
    > familiar with the code. I will not save the editing I do, but it just helps
    > me becuase I have to go through the entire code. I don't know if others do
    > this. If, on the other hand, code is already in a format that's easy for me
    > to read then I'm happy.


    this becomes impractical when kloc > 200 or so

    <snip>

    --
    Nick Keighley
    Nick Keighley, Oct 19, 2006
    #9
  10. sasquatch

    Guest

    On Oct 19, 1:46 am, "sasquatch" <> wrote:
    > X-No-Archive:
    >
    > Are there any good books that provide tips about how to understand and
    > "play with" large C++ programs? It seems like a very important skill,
    > and yet its hardly taught in the universities. Basic programming skills
    > and knowledge of language constructs don't seem enough for
    > understanding larger programs.

    if you find answer " Please tell to me "
    , Oct 19, 2006
    #10
  11. sasquatch wrote:

    > X-No-Archive:
    >
    > Are there any good books that provide tips about how to understand and
    > "play with" large C++ programs? It seems like a very important skill,
    > and yet its hardly taught in the universities. Basic programming skills
    > and knowledge of language constructs don't seem enough for
    > understanding larger programs.
    >

    I don't suggest understanding large programs.
    Many large programs are too large for any one person to
    comprehend and remember. In my years of experience,
    large programs are divided into sections. Most people
    working on the large programs have a general concept
    of the sections, but detailed knowledge about a few.

    Large programs are out of control. Large groups are
    difficult to control.

    --
    Thomas Matthews

    C++ newsgroup welcome message:
    http://www.slack.net/~shiva/welcome.txt
    C++ Faq: http://www.parashift.com/c -faq-lite
    C Faq: http://www.eskimo.com/~scs/c-faq/top.html
    alt.comp.lang.learn.c-c++ faq:
    http://www.comeaucomputing.com/learn/faq/
    Other sites:
    http://www.josuttis.com -- C++ STL Library book
    http://www.sgi.com/tech/stl -- Standard Template Library
    Thomas Matthews, Oct 20, 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. Replies:
    12
    Views:
    1,612
    Dave Thompson
    Jan 10, 2005
  2. Coca
    Replies:
    7
    Views:
    721
    Aidan Grey
    Aug 24, 2004
  3. Replies:
    18
    Views:
    607
    Dave Thompson
    Jan 10, 2005
  4. lone_eagle
    Replies:
    3
    Views:
    621
    psykeedelik
    May 26, 2009
  5. Casey Hawthorne
    Replies:
    14
    Views:
    430
Loading...

Share This Page