Well-written open source?

N

nivlemt1

1) Does anybody know of a good open-source project that I can read to
learn good C programming practices? I have been programming C for some
time, on an off, but mostly doing my own thing[0]. I would like to see
what are the accepted standards/idioms for writting the language. C++
projects are also acceptable :)

2) What strategies do you usually use when reading somebody else's
code? I did download a couple source code projects from here & there
but had a hard time understanding the code. My fault surely, due to my
provincialism.

[0] Mostly a Pascaloid subset of the language that somehow has server
me well these last ~20 years.

I hope these are not too FAQ ... did a Google search and didn't found
much on these topics. Great group by the way, lots of useful info in
these archives.

Any help greatly appreciated

TIA ... TIA ... TIA ... TIA
 
M

Mike Wahler

1) Does anybody know of a good open-source project that I can read to
learn good C programming practices?

This site has over 15,000 open source projects in C:
www.sourceforge.net

You'll have to decide for yourself whether some, any,
or all are 'good', or embody 'good practice'.
I have been programming C for some
time, on an off, but mostly doing my own thing[0]. I would like to see
what are the accepted standards/idioms for writting the language. C++
projects are also acceptable :)

Different people, projects, and managers accept different things,
depending upon their desires, needs, tastes, etc.

A good way to learn the most common general idioms is by reading code
posted by the experts on this newsgroup. And the C FAQ, of course.
2) What strategies do you usually use when reading somebody else's
code?

I will, in roughly this order:

1. Look for and read documentation.

2. Read headers

3. Look for comments in implementation files.

4. Set up 'sandbox'[1], build and run (also watch
with debugger).

5. Look for discussion forums if any

6. Look for available contacts with authors

[1] 'sandbox': an isolated (perhaps a dedicated machine)
environment, in order to protect against possible
system corruption if something goes wrong. The nature
of a project will dictate how 'secure' a sandbox I want.

I did download a couple source code projects from here & there
but had a hard time understanding the code.

First look for the smallest projects you can find. Then try to
break them into smaller components ('good' (imo) projects will
already be structured in a way that facilitates this).
My fault surely, due to my
provincialism.

[0] Mostly a Pascaloid subset of the language that somehow has server
me well these last ~20 years.

Then you haven't been using C. (Standard) C is very
specifically defined. Also, standardized C is less
than twenty years old.
I hope these are not too FAQ ... did a Google search and didn't found
much on these topics. Great group by the way, lots of useful info in
these archives.

Agreed. Suggestion: don't stop at a single reading of any
interesting articles you find. Continue to review them as
you learn. I do, and I find it helps.

-Mike
 
S

slebetman

2) What strategies do you usually use when reading somebody else's
code? I did download a couple source code projects from here & there
but had a hard time understanding the code. My fault surely, due to my
provincialism.

I usually first try to understand the data structures. Usually these
are specified in header files. Once you grasp the data structures
usually you can get a sense of what the code is about even before
reading any of the logic. Reading the code also becomes easier if you
know the data structures involved.
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top