How/where to start reading open source code?

Chiron picture Chiron · Jul 23, 2010 · Viewed 10.2k times · Source

I have always wanted to participate in an Open Source project but once I got the source code, I don't know where to start.

Sinatra framework (Ruby-based) and Apache Maven 3 are in mind but I don't know where to start.

How usually starting reading/viewing open source code?

Thanks for help and time.

Answer

Jon Smock picture Jon Smock · Jul 23, 2010

As you start to read more source code, you'll get better at this; you'll find what works for you.

In the meantime, there are a few strategies:

  1. Pick a feature you like, and try to find the source that implements it
  2. Find the beginning point in the source and step through it, try to understand how it sets itself up
  3. Start poking around aimlessly until you find something that makes you curious (i.e. that's an interesting technique, why have they done that? etc)

One thing that helps me is to put myself in the author's shoes. Why did they do things this way? Was it good/bad? For me, reading source code is about learning new strategies for solving problems. I usually look at a project and think how I would have done it, then I see how they do it and compare.

Specifically for Sinatra, if it were me, I'd setup the most basic Sinatra web app, and then try to figure out how the "get" method sets up a listener. Trace it back to it's Rack roots (Rack is the webserver it uses). You might end up learning a little bit about Rack applications.

You don't have to understand everything you see, but like in the above example, you'll want to get some kind of bearing of what's going on. Then ask more questions and try to find the answers.