We learn programming by writing programs and learning from other programs. Which open source code repositories/programs you suggest for learning/improving programming? While citing reference please also mention the thing you liked about it.
It depends upon your interests, but I had worked with the Quake III codebase, and that was fairly well-written and nice to work with. It is written in C.
I would recommend Scott Hanselman's weekly source code articles, he does exactly what your proposing, that is read more source code to get better. It's worth the read.
You'll find lots of examples. But has Jim Buck said, it depends on your interests. I've learned a metric s-- ton of "stuff" from the SharpDevelop source.
If anyone has a copy of Code Reading by Diomidis Spinellis, what open-source projects does he write about there?
@Avinash: If you want to learn more about programming in general, I would recommend both Code Reading and Code Quality by Spinellis. They have code samples from various projects, all FOSS, I believe, so you can not only read about them, but go and get the version discussed in the book and the latest version to read more code from them and learn.
The Linux kernel is a very good way to learn.
I know it may be difficult to dive into because of the multi-architectural structure and the large amount of code but there's some very good article to go slowly inside, like this one from Tim Jones.
I've learned a lot by looking at a specific subject, like the FAT driver implementation and filesystems abstraction.
I can recommend Simon Tatham's puzzle collection. It's a series of puzzle games (minesweeper, sudoku, fifteen) available for Windows, OS X and Linux (and as java applets). The architecture is quite simple: there's a front-end interface with three implementations (one per platform), a back-end interface with one implementation per game (I've given three examples) and a mid-end that makes them talk together, do serialization and other neat stuff.
Basically, it's good OOP. Written in C. It's easy to contribute to (I implemented the Filling and Range games) since it's well documented, and it's easy to read.
I thoroughly recommend Code Complete 2nd Edition (ISBN: 0735619670) written by Steve McConnell. For the most part, it uses C++ as its lingua franca, however it has occasional mentions of Visual Basic code. In fact, this book was actually used throughout my college's computer science department for advocating good coding practices. And, to be frank, after reading this book, my coding skills and productivity improved by leaps and bounds.
Relatively small, yet with enough complexity to be able to learn from, my vote goes to:
Apache's Log4Net logging framework.
It's source code is very readable, and "cross-platform" [compilable on: .NET 1.0, 1.1, 2.0, CF, MONO...], thus being valuable for lesson in "cross-platform" C# development...
One of the best pieces I've found of clear and concise source code is the jQuery source. Whether you like Javascript or not, it makes a great case against advocates of "code being the documentation".
There's lots of comments but it's not ascii artwork and you can see clear reasoning going - the comments make you know exactly what is trying to be achieved.
An example (full source):
(function(){
var
// Will speed up references to window, and allows munging its name.
window = this,
// Will speed up references to undefined, and allows munging its name.
undefined,
// Map over jQuery in case of overwrite
_jQuery = window.jQuery,
// Map over the $ in case of overwrite
_$ = window.$,
jQuery = window.jQuery = window.$ = function( selector, context ) {
// The jQuery object is actually just the init constructor 'enhanced'
return new jQuery.fn.init( selector, context );
},
// A simple way to check for HTML strings or ID strings
// (both of which we optimize for)
quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,
// Is it a simple selector
isSimple = /^.[^:#\[\.,]*$/;
jQuery.fn = jQuery.prototype = {
init: function( selector, context ) {
// Make sure that a selection was provided
selector = selector || document;
// Handle $(DOMElement)
if ( selector.nodeType ) {
this[0] = selector;
this.length = 1;
this.context = selector;
return this;
}
// Handle HTML strings
if ( typeof selector === "string" ) {
// Are we dealing with HTML string or an ID?
var match = quickExpr.exec( selector );
// Verify a match, and that no context was specified for #id
if ( match && (match[1] || !context) ) {
// HANDLE: $(html) -> $(array)
if ( match[1] )
selector = jQuery.clean( [ match[1] ], context );
// HANDLE: $("#id")
else {
var elem = document.getElementById( match[3] );
// Handle the case where IE and Opera return items
// by name instead of ID
if ( elem && elem.id != match[3] )
return jQuery().find( selector );
...