Thread: The best way to read OO code?

  1. #1
    Android geek@02's Avatar
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    470

    The best way to read OO code?

    This might be a silly question.

    What's the best way to read a complicated, interweaved OO code?:

    1. Start from the main() and go through each function call to get to know the classes?
    2. Start from the beginning of the 1st cpp file and read every file back-to-back?
    3. Another way?

    Thanks. Good day to all.

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    Read the header files, as with any code. For OO code, I would read the base classes first and then the implementations (going down the tree).

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    I like to start from main (or a class) and trace backward from there. That usually works pretty good since most OOP uses the 'top-down' design approach. That way, you get to study the abstraction before you get to the 'guts' of the code.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. array bounds overflow
    By BendingUnit in forum C Programming
    Replies: 3
    Last Post: 06-18-2006, 10:45 PM
  2. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  4. << !! Posting Code? Read this First !! >>
    By biosx in forum C++ Programming
    Replies: 1
    Last Post: 03-20-2002, 12:51 PM
  5. << !! Posting Code? Read this First !! >>
    By biosx in forum C Programming
    Replies: 1
    Last Post: 03-20-2002, 12:51 PM