Thread: learning to work with SDKs & source code out there...

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    1

    learning to work with SDKs & source code out there...

    Hi all,

    I'm a newbie programmer, somewhat comfortable programming my own applications from scratch in Win32API or .NET. What I'm having trouble though, is understanding and working with other people's code, like various SDKs and source code widely available on the internet. I just don't know what to do after I unzip the file.
    For example, I'd download the source code of some open source application, unzip it in some directory, and notice that there's a bunch of directories, a bunch of project files, maybe a couple solution files, hundreds of .h files, hundreds of .c files and so on and so forth.
    Forgive my ignorance, but what on earth am I supposed to be doing with all this? I understand that I'd need to compile something, probably, but which project or which solution am I supposed to compile? If I pick a random one and compile it, I end up with a bunch of errors I am clueless about. and then what? I'd have to figure out how the program works, but with hundreds of files floating around, where do I begin? (assuming no helpful documentation...)

    I've learned to program mostly on my own, reading books and tutorials, but no books out there seem to talk about how to figure out stuff other's have written. Perhaps it's supposed to be obvious. Well, it isn't for me.
    Anyhow, I know that this forum is filled with experienced programmers, and they all must have had a transition from being able to program things on their own to being able to work with stuff other's have written. So if anyone could share their experience with learning how to do this, I'd be much indebted!

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    I'm not really sure about the answer to your question, but I suspect you first have to know how to compile one of your own programs when you have multiple .cpp files and multiple .h files. Can you do that?

    I would guess that if you want to use all the functions and classes declared in the .h files that you downloaded, you would have to add all those .h files to your project--as well as all the .cpp files where they are defined. Whether you can do that en masse or not, I don't know.
    Last edited by 7stud; 05-14-2005 at 07:35 PM.

  3. #3
    Registered User
    Join Date
    Apr 2005
    Posts
    22
    Well psasidicrum in my (rather limited) experience it is hard to understand code without any kind of documentation unless its not very complex. If you download source code with hundreds of header and source files and no documentation there is basically no way you can understand it. Libraries written for use by other programmers will always have some kind of documentation, you just need to look for it wherever you've downloaded the source code. it's often going to be in a separate zip file.
    If you get a few headers and source files and no documentation what you could do is find the main cpp or c file and look at files #included in it. then you look at the files included in those files, etc. this way you will get at least some kind of overview of the structure of the program. also, if you have a file called e.g. LinkedList.hpp then you'll know its a file implementing a linked list.
    If you download sources of an open source application to learn how other programmers code then i guess you don't have to compile the entire application. often it is most useful to look at individual modules, especially the most atomic ones, maybe try to write your own code that uses those modules. however if you really want to compile the whole application then picking a project file at random and compiling it is definetely not going to work. there should be some kind of file with instructions how to compile the source code.
    I think that learning from other people's source code is a good idea but trying to understand code that is way over your head is frustrating and of very little benefit. I'd try to learn from code that is not much higher than your level of ability. also, even if the code is at your level of ability trying to understand a project with more than 20-30 files it gets too difficult tracking all the file inclusion etc.
    here's a couple of sites where you can download source code:
    www.planet-source-code.com
    www.thefreecountry.com/sourcecode/cpp.shtml
    hope this was helpful.
    Last edited by anykey; 05-14-2005 at 08:22 PM.

  4. #4
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    From my experience, the first thing you have to do in order to understand that source code you downloaded is to fix all those errors you found when compiling. Those are usually because: A) they wrote code that was dependent for their complier; or B) the code you downloaded is a bit outdated from the libraries they're using. This is a great exercise regardless of what you're trying to do, since there really is no book or tutorial you can read to tell you how to read other peoples code. It's something you just have to get good at on your own.

    The second thing to do would be focus on only what you need to accomplish. A while back, when working with the Maya API trying to export geometry, I was bombared with their scene graph, their entire object hierarchy and interface, and MEL scripting. Instead of learning about each piece and all its intricacies, I first looked for the functionality that would solve my problem (exporting vertices and animation hierarchies/frames). Of course, I had to dive into the scene graph and their object hierarchy to do that, but I started from the bottom up: figured out what I needed, then slowly kept stepping up until I can solve the problem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Documenting Source Code
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 01-04-2008, 12:18 PM
  2. DxEngine source code
    By Sang-drax in forum Game Programming
    Replies: 5
    Last Post: 06-26-2003, 05:50 PM
  3. Lines from Unix's source code have been copied into the heart of Linux????
    By zahid in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 05-19-2003, 03:50 PM
  4. Source Code Beautifier
    By Hammer in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 05-05-2002, 09:21 PM
  5. C source code for int25 or code help
    By Unregistered in forum C Programming
    Replies: 0
    Last Post: 09-26-2001, 02:04 AM