1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Reading other people code

Discussion in 'General Programming Chat' started by Nick1, Jul 20, 2012.

  1. Nick1

    Nick1 Junior Member

    Joined:
    Oct 16, 2009
    Messages:
    196
    Likes Received:
    45
    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: Jul 21, 2012
  2. amazonian raider

    amazonian raider Junior Member

    Joined:
    Mar 6, 2012
    Messages:
    114
    Likes Received:
    23
    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.
     
    • Thanks Thanks x 1
  3. seeplusplus

    seeplusplus Power Member

    Joined:
    Aug 18, 2008
    Messages:
    511
    Likes Received:
    163
    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.
     
    • Thanks Thanks x 1
  4. Irukichan

    Irukichan Registered Member

    Joined:
    Jan 19, 2010
    Messages:
    75
    Likes Received:
    40
    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.
     
    • Thanks Thanks x 1
  5. tacopalypse

    tacopalypse Executive VIP Jr. VIP Premium Member

    Joined:
    Nov 30, 2009
    Messages:
    980
    Likes Received:
    2,485
    Home Page:
    [​IMG]
     
    • Thanks Thanks x 6
  6. s0ap

    s0ap Executive VIP Jr. VIP Premium Member

    Joined:
    Sep 23, 2008
    Messages:
    230
    Likes Received:
    810
    Occupation:
    :] guess
    Location:
    Congo/DRC
    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.
     
    • Thanks Thanks x 1
  7. SnowWar

    SnowWar Power Member

    Joined:
    Mar 3, 2012
    Messages:
    595
    Likes Received:
    48
    Occupation:
    Pure student :p
    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.
     
    • Thanks Thanks x 1
  8. Kiopa_Matt

    Kiopa_Matt Registered Member

    Joined:
    Jun 3, 2011
    Messages:
    99
    Likes Received:
    11
    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.
     
    • Thanks Thanks x 1
  9. kiggd

    kiggd Junior Member

    Joined:
    Apr 28, 2012
    Messages:
    116
    Likes Received:
    44
    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.
     
    • Thanks Thanks x 1
  10. msimurin

    msimurin Regular Member

    Joined:
    Sep 21, 2009
    Messages:
    243
    Likes Received:
    92
    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
     
    • Thanks Thanks x 1
  11. Huy Phan

    Huy Phan Jr. VIP Jr. VIP

    Joined:
    Sep 3, 2012
    Messages:
    910
    Likes Received:
    545
    Home Page:
    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.
     
    • Thanks Thanks x 1
  12. lancis

    lancis Elite Member

    Joined:
    Jul 31, 2010
    Messages:
    1,632
    Likes Received:
    2,384
    Occupation:
    Entrepreneur
    Location:
    Milky Way
    Home Page:
    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.
     
    • Thanks Thanks x 1