reading source codes
I am pretty comfortable with c++ I have been looking at source codes to better understand it. It is easy to read a few pages of code for a small program but waht about thousands od lines of code, it takes a long time to understand it. any tips on reading code faster or easier?
3dmodeler
The trick is ... don't read the code. [smile]
When you need to work with a piece of code, all that is relevant (usually) is the function prototypes and type declarations you need. You rarely care about the code behind them (this assumes that this is a relatively well tested codebase). If the code has good documentation, you may not even need to open any of the files that make up the program.
As you get more experienced, you will find it easier to navigate large codebases quickly.
Also, this might be worth a read.
When you need to work with a piece of code, all that is relevant (usually) is the function prototypes and type declarations you need. You rarely care about the code behind them (this assumes that this is a relatively well tested codebase). If the code has good documentation, you may not even need to open any of the files that make up the program.
As you get more experienced, you will find it easier to navigate large codebases quickly.
Also, this might be worth a read.
Reading source code to learn how to program is one of the worst ways to learn programming. That's like watching spanish soap operas, trying to learn spanish purely from context. It might be possible, but it's going to be a lot harder than if you go out, buy a spanish book, and actually start SPEAKING spanish, no matter how poorly.
Writing programs -- no matter how simple -- is almost always a better way to learn programming than by looking at source code someone else wrote.
Writing programs -- no matter how simple -- is almost always a better way to learn programming than by looking at source code someone else wrote.
I have been learning c ++ with books I just wanted to see code the way other people might use it (lots of differences in developing a project) Reading it i think can help to see how something is done.
I read that article rip-off thanks i alway heard it was a good thing to read sourcecode I guess i am wrong
3dmodeler
I read that article rip-off thanks i alway heard it was a good thing to read sourcecode I guess i am wrong
3dmodeler
Well i'm not as experienced as most of the people here that will give you advice on learning to program, but i don't see reading source code as a bad thing. Or course, it's always better to do some exercises, hands-on experience is best, but reading other peoples code can give you insight into their methods and styles. You just have to remember that their code may not the best and a book will instruct you of proper usage of the language. And it's only really worth it if the code is well commented. I don't think anyone would disagree that tutorials can be helpful, but just reading source code without any explanation on what it does can also be a good exercise.
At least, that's what i think. [smile]
At least, that's what i think. [smile]
right reading it isn't totally bad but there are proper steps whne doing it. Take me for instance. One day i started reading some source from the quake 3 engine that was release under gpl. I didn't understand anything when i began even though i had written many programs. For one, the tool i used was totally lame. Visual studio regardless of what ever one says is the best tool for beginners. It has superb searching and debuging is the best i have seen. ok when reading from source you have understand some context to grasp the rest. its like when reading we often use context clues to learn new words. Its kinda the same except in coding code isn't straight forward to beginners
Quote:Original post by owiley
...except in coding code isn't straight forward to beginners
Yes, i agree that it complete n00bs shouldn't just sit down and start reading source code when they barely know how to program.
don't read the code. Compile it, run it, put a breakpoint where you want to figure out how something works. Step through the code till ya understand it [smile];
-me
-me
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement