Reading other people code

Nick1

Junior Member
Joined
Oct 16, 2009
Messages
196
Reaction score
42
I have a lot of trouble editing other people's projects.

For one, the scale is a bit daunting, I don't think I ever wrote anything that is larger then 600-700 lines.
Instead of coding everything from scratch, in theory at least, I'd rather take apart an open source project and change the stuff I need but I am having a hard time doing this unless there is very extensive documentation.

Obviously, to dissect something that is not yours is harder, but is there any methodology to make the task easier? For those with more experience, how did you get your feet wet in open source projects?


Thanks BHW
 
Last edited:
A big part of being able to edit someone else's code (or even your own code when it's not fresh in memory) relies on how it was written/organized in the first place. When you're looking at a large open source project, rather than trying to read it line by line and see what's going on, it would be worth spending some extra time upfront learning how that project is organized so you can look a particular section that interests you(instead of the whole thing) and get an idea of what's going on and what needs to be changed.
 
The Unified Modelling Language (UML) is for this exact thing.

Also the type of language used. C++ for example is great, as you can look at the header files, and the implementation is not something you may need to concern yourself with apart from the part in which you are working on. C on the other hand is procedural, and so the need to follow the code from top to bottom is required.

The debugger is your friend.
 
Everyone hates reading everyone else's code.

As mentioned above, you probably shouldn't be reading through an entire massive project, just sections that are relevant to what you are working on. As you get more familiar with common practices, you will be able to parse different techniques easily and find exactly what you're looking for even if someone does it completely different than what you expect.
 
you_down_wit_OPC-yeah_you_know_me.png
 
If you plan to ever go into industry, get used to it and embrace it now. For my latest job we have a 20-60 page documents detailing coding standards for each language used, and they are enforced religiously. If you are only writing code for yourself or if you are still learning, do whatever you are most comfortable with but be prepared to adapt in the long run.
 
Before doing something you need to understand the total planning. If you miss a bet of it, you will get your project unsuccessful. So to make it happen make the design first.
 
Sorry, don't think there's an easy solution for you. It's simply called practice, and gaining experience. Just keep digging around, and it'll start becoming easier and easier.
 
Do everyone a favor, take the opportunity of reading other peoples code to learn to document your own. I just worked on a project from a horrible horrible outsourced programmer with zero documentation of why any of his code was doing things. Reverse engineering his crap design, amateur design was hell.
 
the more you code the easier to read it is, there is no magic trick, some guys will do it in a bad way but still its easier for you to solve it the more experience you have
 
I find it hard to understand why people don't use commenting in their code. Damit, that's why it was invented :)
It would make reading code much more easier.
 
Let me admit it for you. :-)

You can't read others' code. I mean you can on a small scale, but it will take you years to understand the entire picture if the project is large enough.

The only relatively fast way to dive into others' people code is debugging.
 
Back
Top