Reading an unfamiliar codebase.

As programmers, we have all heard that we should be reading more code. Who, some might ask, would bother reading a book by an author who doesn't read? So how can our coding improve without reading the code of others?

The biggest stumbling block I've found in my own attempts to read unfamiliar code is that there is just so much of it. There is no beginning and no end, so there's no obvious way to know where to start.

I'm talking about large projects here. Projects you use daily, would like to contribute to, and which are authored by open-source developers you respect. One interesting idea is to simply start with the most frequently-edited files. This would seemingly indicate the more interesting parts of the code -- those under active development.

Here is one way to list them in order of edit frequency:

git log  --date=iso --format="%h %ai" --name-only  | sort | uniq -cd | sort -n

You can also limit the git log using --since or -n:

# January 1st, 2016 or newer
git log --since=2016-01-01

# last 100 commits
git log -n 100

Comments !