Understanding large C++ programs

S

sasquatch

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

Victor Bazarov

sasquatch said:
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
 
J

Jim Langston

sasquatch said:
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.
 
N

Noah Roberts

sasquatch said:
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.
 
?

=?ISO-8859-1?Q?Jens_M=FCller?=

sasquatch said:
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 ...
 
A

AnonMail2005

sasquatch said:
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.
 
S

sasquatch

Jens said:
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.
 
R

ralph

sasquatch said:
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
 
N

Nick Keighley

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

chandrahasanstar01

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 "
 
T

Thomas Matthews

sasquatch said:
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
 

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,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top