LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 09-15-2007, 06:22 PM   #1
JMJ_coder
Member
 
Registered: Apr 2006
Distribution: Fedora
Posts: 478

Rep: Reputation: 30
Good Code Examples


Hello,

Almost all my sources (Professor, books, etc.) say that to learn how to program effectively two important things are needed - 1. practice and 2. looking at good examples of code. So, I am asking for good projects that are well programmed and can be looked at as examples of quality programming style.


Thanks in advance.
 
Old 09-16-2007, 11:05 AM   #2
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,119

Rep: Reputation: 818Reputation: 818Reputation: 818Reputation: 818Reputation: 818Reputation: 818Reputation: 818
Two excellent sources:
  1. Brian W. Kernighan, Dennis M. Ritchie The C Programming Language, Second Edition.
  2. Steven G. Kochan, Patrick H. Wood Topics in C Programming, Revised Edition.
Kernighan and Ritchie is the "bible" and is possibly the best "style" you can adopt.

Kochan and Wood is a beautifully-written how-to, filled with hundreds of working example programs that cover pretty much everything you'll ever want or need to do.

Yes, both of these are "old" but, frankly, they're just about the best. Amazon stocks both.
 
Old 09-16-2007, 12:35 PM   #3
JMJ_coder
Member
 
Registered: Apr 2006
Distribution: Fedora
Posts: 478

Original Poster
Rep: Reputation: 30
Hello,

Quote:
Originally Posted by tronayne View Post
Two excellent sources:
  1. Brian W. Kernighan, Dennis M. Ritchie The C Programming Language, Second Edition.
  2. Steven G. Kochan, Patrick H. Wood Topics in C Programming, Revised Edition.
Kernighan and Ritchie is the "bible" and is possibly the best "style" you can adopt.

Kochan and Wood is a beautifully-written how-to, filled with hundreds of working example programs that cover pretty much everything you'll ever want or need to do.

Yes, both of these are "old" but, frankly, they're just about the best. Amazon stocks both.
I have The C Programming Language. Thanks for the information on the other book.
 
Old 09-16-2007, 12:36 PM   #4
JMJ_coder
Member
 
Registered: Apr 2006
Distribution: Fedora
Posts: 478

Original Poster
Rep: Reputation: 30
Hello,

How about examples of real life projects?
 
Old 09-16-2007, 12:47 PM   #5
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,119

Rep: Reputation: 818Reputation: 818Reputation: 818Reputation: 818Reputation: 818Reputation: 818Reputation: 818
Quote:
Originally Posted by JMJ_coder View Post
Hello,

How about examples of real life projects?
That's what you'll find in Kochan and Wood.
 
Old 09-16-2007, 12:50 PM   #6
JMJ_coder
Member
 
Registered: Apr 2006
Distribution: Fedora
Posts: 478

Original Poster
Rep: Reputation: 30
Hello,

Quote:
Originally Posted by tronayne View Post
That's what you'll find in Kochan and Wood.
Oh, o.k. - I thought that book would only provide academic examples.

Does this book provide only C code? What about C++ code - any good books on that (I am currently studying C++ at the University; I won't get to C until at least spring)?

Again, thanks.
 
Old 09-16-2007, 02:41 PM   #7
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

I found this book extremely interesting:
Quote:
"Coding Reading: The Open Source Perspective", Diomidis Spinellis, ISBN 0-201-79940-5
It's about *exactly* what you're asking about (real world code examples - *lots* of them!), but it also discusses these examples. Discusses what's good, what's bad; how it works, how to *understand* how it works. It discusses "micro" features (like when to use a "for loop", "macro features" (like how to organize source code into project directories) and practical stuff that's seldom discussed in academic books (like the implications of using tabs vs whitespace for indentation).

I honestly think you'd be well served by buying (or borrowing) a copy of this book (and looking at the some of the complete source code on the accompanying CD).

IMHO .. PSM

PS:
This link shows some of the Open Source example projects analyzed and discussed in the book:
http://www.spinellis.gr/codereading/source.html

Last edited by paulsm4; 09-16-2007 at 02:46 PM.
 
Old 09-16-2007, 05:15 PM   #8
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,119

Rep: Reputation: 818Reputation: 818Reputation: 818Reputation: 818Reputation: 818Reputation: 818Reputation: 818
Quote:
Originally Posted by JMJ_coder View Post
Does this book provide only C code?
Yes, it's C. C++ I haven't really found a good book other than the original publication by the author of the language.

The Kochan & Wood is full of real, working programs (not full-blown applications, little, useful pieces that show you how things actually work) accompanied by a detailed discussion of each of the built-ins and Standard C Library functions being demonstrated.

In the immortal words of M. Douglas McIlroy, a program or function should do one thing and do it well; that's the philosophy followed by Kochan and Woods and a pretty good one to stick with as life goes on. You build big applications from little pieces of the puzzle and it does not hurt to have a good reference that shows you how a library function is supposed to work so you can do less work as you go.

One of the example programs is a working shell; not the gazillion lines of the Bourne, Bash or Korn shells but including the essential functions in a small, easy-to-understand demonstration program.

Not a bad way to learn, all in all.

Best of luck to you.
 
Old 09-16-2007, 07:39 PM   #9
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 50
Here is a real life example from my research work. I don't know whether it is good C++, I would like to think it is, it does the job it is supposed to which is good enough for me. You'll have to excuse spelling mistakes, grammar and such things in the documentation, but it's only really for me and my supervisor and proofreading is a pain.

If nothing else, at least it is very small, it's not like reading the source for apache. plus, it demonstrates a lot of c++ features.

http://yuffie.khn.org.uk/~kev82/dephandler/index.html
 
Old 09-17-2007, 08:03 PM   #10
JMJ_coder
Member
 
Registered: Apr 2006
Distribution: Fedora
Posts: 478

Original Poster
Rep: Reputation: 30
Hello,

Quote:
Originally Posted by paulsm4 View Post
Hi -

I found this book extremely interesting:


It's about *exactly* what you're asking about (real world code examples - *lots* of them!), but it also discusses these examples. Discusses what's good, what's bad; how it works, how to *understand* how it works. It discusses "micro" features (like when to use a "for loop", "macro features" (like how to organize source code into project directories) and practical stuff that's seldom discussed in academic books (like the implications of using tabs vs whitespace for indentation).

I honestly think you'd be well served by buying (or borrowing) a copy of this book (and looking at the some of the complete source code on the accompanying CD).

IMHO .. PSM

PS:
This link shows some of the Open Source example projects analyzed and discussed in the book:
http://www.spinellis.gr/codereading/source.html
Thanks!
 
Old 09-17-2007, 08:05 PM   #11
JMJ_coder
Member
 
Registered: Apr 2006
Distribution: Fedora
Posts: 478

Original Poster
Rep: Reputation: 30
Hello,

Quote:
Originally Posted by tronayne View Post
Yes, it's C. C++ I haven't really found a good book other than the original publication by the author of the language.

The Kochan & Wood is full of real, working programs (not full-blown applications, little, useful pieces that show you how things actually work) accompanied by a detailed discussion of each of the built-ins and Standard C Library functions being demonstrated.

In the immortal words of M. Douglas McIlroy, a program or function should do one thing and do it well; that's the philosophy followed by Kochan and Woods and a pretty good one to stick with as life goes on. You build big applications from little pieces of the puzzle and it does not hurt to have a good reference that shows you how a library function is supposed to work so you can do less work as you go.

One of the example programs is a working shell; not the gazillion lines of the Bourne, Bash or Korn shells but including the essential functions in a small, easy-to-understand demonstration program.

Not a bad way to learn, all in all.

Best of luck to you.
Thanks! They have old copies from Amazon for less than a dollar - plus S&H. I looked at Kochan & Wood's website and it looks like a new edition is in the works.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Good Ajax Code Examples Neko_D Programming 5 04-09-2007 04:17 PM
LXer: Cuba and Venezuela - Unlikely Good Examples of Open Source Preference LXer Syndicated Linux News 0 02-21-2007 05:16 PM
XML Code Examples FLLinux Programming 1 01-17-2006 02:21 AM
Anyone know where I could get some good examples of sendmail files? WorldBuilder Linux - Networking 1 05-14-2003 05:12 AM
Looking for a good list of shell commands with examples jk1 Linux - Newbie 4 06-11-2002 09:09 PM


All times are GMT -5. The time now is 11:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration