

Ways to read source code and learn? - dwong

I've been reading through source code for various programs to get better at programming. I know that many of the people here also do this.<p>I'm wondering what your approach is when you're trying to learn from source code (not debug, but reading it to get better at programming). Do you go line by line, follow a top-level function call, etc? Also, if you're familiar with the syntax, do you quickly skim over boilerplate code to be more efficient?<p>Thanks for any advice. Trying to speed up my learning process.
======
gexla
Seems like a waste of time to go out of my way to do this. I would rather be
spending that time building something or getting away from my computer.

However, I do sometimes have to look through code for the following
situations.

I can't figure out how something works through the docs. Something I really
need to use isn't working as expected. If I know something I'm new to could be
done in a better way and I would probably save time by looking how someone
else has done it. I need to add a feature to code someone else has provided.

There are plenty of opportunities to look through code other people have
written in the normal course of my work without having to set aside special
time for this.

Just spend your time coding and be proud of the crap code that you create at
first. You will get better!

~~~
dwong
Thanks for the response. I'm a computer science student, so I don't have a
chance to read actual program code for classes/etc.

------
aws540
I usually pick something interesting on github and do the following:

1\. pick a feature that i find interesting 2\. trace it all the way through,
line by line (like stepping into a call with a debugger) 3\. using an IDE is
really helpful because you can click into methods and jump around sources.
(especially if docs are attached to sources)

look up every function and keyword you do not understand

I try to pick a simpler feature first, then if i am still hungry for knowledge
I'll pick a more complex one that is related to the first feature.

