What source code are you reading?
I find it interesting to read and study source code from various projects. I'm currently reading and studying the source code to :
Source Code Reader
Want my first professional project? It'll keep you glued for years to come....
I probably read the Windows source code the most (I have legal access to it). Lots of nuggets in there.
Reading source code is not particularly useful, particularly the crappy source code the makes up the vast majority of OSS projects.
To be fair, the vast majority of closed source projects also consist of crappy code.
I personally enjoy reading kernel, web server, network stacks, and proxy server sources. Apache was commented on. Minix and Linux was commented on. Linux net stack was commented on. Forgot the name of the publisher. It's easier to read in print and with a little bit of help. If you can handle huge softwares that's great, but generally I stick to the little things (small web servers or web accelerators) still in alpha to keep the reading to a minimum.
Squid is interesting in that it uses a single threaded model. Another interesting http server is thttpd. The whole thing is like 5 C files.
Mr. Fancypants - I understand you grasp all useful techniques and coding issues from the ether, but some of us don't have the capability -- and we improve ourselves by learning from others. You know, like writers read other writers' books every once in a while.
I am working my way through the .NET framework at the moment. Some of the code does seem very naïve, but I guess that's probably the optimiser, rather than the MS guys ;-)
How do you read source code? I'd like to know.
Procedural is usually easiest to read; Nothing inherent, I think, but that's my experience.
Ged: It helps when you have a pretty good idea how something works, then you're just checking your understanding, though still with the occassional suprise, of course.
Golgotha & Abuse, the games from Crack.com (C++, lisp)
I usually start with the highest level and go down, i.e. I start with the GUI (if there is one), move down to the next highest-function set, and go from there, looking up the code for functions as I encounter them, until I get to the "bottom". It's easy to make a diagram of how the code works from this, if you have a big sheet of paper or visio, or some other tool like visio (preferred to do it electronically, or your diagram is going to have a LOT of overlapping lines, unless you're superman at predicting entanglements, and if you are, sweet!)
Thanks for the replies guys. Thought I would add some more:
Source Code Reader
Ohh yea... and I normally identity a feature the program has (by using it) that I would like to know how it works and then I try to find the appropriate source code. (Sorry, that sentence is wordy heh.)
Source Code Reader
>How do you read source code? I'd like to know.
I prefer developing to reading other peoples' source code. In fact, I can't think of anything I less enjoy than reading other peoples' code. I've never been a maintenance programmer and never will be.
I tend to use "Understand for C", by www.scitools.com to read other people's code. You feed this tool a list of subdirectories containing source code. It traverses the subdirs, building a database of all calls, references, objects, etc.
AllanL5 isn’t that called reverse engineering? You generate design diagrams from the code. I think that is useful to understand how an application has been programmed and designed. But if you need to change the design can you use the tool to rebuild the code again? Have anyone had any experience with these kind of tools? How is the quality of the code generated? Is it readable?
Why yes, I believe that IS called 'reverse engineering'. I seem to do it an awful lot -- except I'm only reverse engineering what others have authorized me to reverse engineer.
Apache Struts, because the documentation has some frustrating holes in it.
I'm just getting into TDD, so any tutorials / examples of that. I'm not a mature enough programmer to tackle reading a major product (i.e. Apache or Mozilla) and grok it. I think once I grasped one section it would fall out of my brain as soon as I pushed another one in.
For getting to know C++ techniques a bit better I recommend reading the Boost libraries. The MFC C++ library is good reading, and if you are into Delphi try the VCL (Visual component library). The VCL is actually easily read.
Fog Creek Home