Jump to content

Code reading/understanding

- - - - -

  • Please log in to reply
5 replies to this topic

#1
psepheroth

psepheroth

    Learning Programmer

  • Members
  • PipPipPip
  • 31 posts
I am currently reading a code. It has many classes and I have no idea of the structure yet. I even have no idea of how it work inside.
Now my question is, what are your methods of learning the code compose of several classes as defined in the situation above?
Do you have a technique? tips? tricks?

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
It varies widely. I've been learning one program that has a few hundred source files for about 5 years. I can find chunks of code fairly easily, now, and understand the major structure. A lot of it is just slowly getting the feel for the major structure, and slowly gleaning the details of various methods/variables as you explore it.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
psepheroth

psepheroth

    Learning Programmer

  • Members
  • PipPipPip
  • 31 posts

WingedPanther said:

It varies widely. I've been learning one program that has a few hundred source files for about 5 years. I can find chunks of code fairly easily, now, and understand the major structure. A lot of it is just slowly getting the feel for the major structure, and slowly gleaning the details of various methods/variables as you explore it.

How did you do it?

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
I started with a more limited area of functionality. While working with it, I'd run into a function in another file/code area. Sometimes I'd have to do a code search (jEdit makes it pretty easy) to locate the function in question. Once I understood that, I'd return to the area in question and plow on. During that time, I did a couple fixes to a rounding function that's used by 90% of the software in question, added new functionality, fixed a bug in about 3 spots in a 3000 line function, etc. The fact that Delphi makes it easy to connect form elements with functionality helps a lot, too :)

I've also had to learn several other languages, translate logic into those languages, etc. You work it 40 hours a week, for 5 years, and stuff gets absorbed. Just try to understand what you're dealing with now, and you'll start assembling things together as you work on it.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
psepheroth

psepheroth

    Learning Programmer

  • Members
  • PipPipPip
  • 31 posts

WingedPanther said:

I started with a more limited area of functionality. While working with it, I'd run into a function in another file/code area. Sometimes I'd have to do a code search (jEdit makes it pretty easy) to locate the function in question. Once I understood that, I'd return to the area in question and plow on. During that time, I did a couple fixes to a rounding function that's used by 90% of the software in question, added new functionality, fixed a bug in about 3 spots in a 3000 line function, etc. The fact that Delphi makes it easy to connect form elements with functionality helps a lot, too :)

I've also had to learn several other languages, translate logic into those languages, etc. You work it 40 hours a week, for 5 years, and stuff gets absorbed. Just try to understand what you're dealing with now, and you'll start assembling things together as you work on it.

Thanks for sharing.
Uhm...do you try to draw it out? or create your own flow chart of the code as you try to trace it?

#6
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
There have been a few tricky bits of logic that I flow-charted out, but I mainly used an editor with great search and code-folding capabilities, along with the default editor for additional features. jEdit is still my favorite editor for it's powerful search capabilities.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users