Ways to read source code and learn?
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.
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?
Thanks for any advice. Trying to speed up my learning process.
3 comments
[ 2.9 ms ] story [ 14.8 ms ] thread1. 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.
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!