Slashdot Mirror


Ask Slashdot: How To Start Reading Other's Code?

BorgeStrand writes "I'm reviving an open source project and need to read up on a lot of existing code written by others. What are your tricks for quickly getting to grips with code written by others? The project is written in C++ using several APIs which are unknown to me. I know embedded C pretty well, so both the syntax, the APIs and the general functionality are things I wish to explore before I can contribute to the project."

6 of 254 comments (clear)

  1. Unit Tests by Anonymous Coward · · Score: 5, Informative

    If possible, I would try writing unit tests for the existing code. This tests your understanding of what you are reading and will come in handy later if you change the code. If unit tests already exist then I suggest that you read them since they will tell you the intention of each function.

  2. Doxygen by mapinguari · · Score: 5, Informative

    Even without Doxygen's specific format for comments, you can use it to graph object relationships, call-trees, etc.

    You can generate docs limited to a few files or classes if you just want to focus on them.

    www.doxygen.org

  3. Re:How to read code by cdp0 · · Score: 5, Informative

    Are there tools that do this automatically?

    Have a look at Scitools Understand.

  4. Re:Test and Break by mooingyak · · Score: 4, Informative

    Also, vowels apparently used to be very expensive in C variable names "back in the day."

    Certain early C implementations would only use the first 8 characters of a variable name. At that point, the vowels are usually the most expendable when coming up with names.

    --
    William of Ockham had no beard. The most likely explanation is that it was chewed off by squirrels every morning.
  5. Re:Maybe. by Endophage · · Score: 4, Informative

    There are plenty of design patterns other than MVC and depending on the particular application, MVC may not even be applicable.