By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,413 Members | 999 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,413 IT Pros & Developers. It's quick & easy.

How to understand (reverse engineer) other people's code?

P: 4
I have been given the happy task of attempting to document software which only has sparse doxygen comments throughout. I have identified an entry point (first class/method called) and vaguely sketched out UML activity and class diagrams which is an on-going process in the attempt to understand the code structure and processes. I do have other developers to throw my questions to but I don't think I have comprehended enough of the code to have got to that point yet.

It's mainly an unstructured approach that I'm taking, as I haven't had a lot of practice in doing this. My question is, can anyone suggest an approach one might take when handed source code, to firstly understand the processes and structures within, and secondly to generate documentation from it. If a uniform approach does exist, I'd like to try it out here!

Additionally, could anyone suggest a URL (or URLs) which may have this sort of information.

thanks.
Jun 4 '07 #1
Share this Question
Share on Google+
8 Replies


Expert 100+
P: 181
I have been given the happy task of attempting to document software which only has sparse doxygen comments throughout. I have identified an entry point (first class/method called) and vaguely sketched out UML activity and class diagrams which is an on-going process in the attempt to understand the code structure and processes. I do have other developers to throw my questions to but I don't think I have comprehended enough of the code to have got to that point yet.

It's mainly an unstructured approach that I'm taking, as I haven't had a lot of practice in doing this. My question is, can anyone suggest an approach one might take when handed source code, to firstly understand the processes and structures within, and secondly to generate documentation from it. If a uniform approach does exist, I'd like to try it out here!

Additionally, could anyone suggest a URL (or URLs) which may have this sort of information.

thanks.
there are whole lot of way to do this, what i would prefer is putting some printf in all the functions, then we can come to know about the function calls.
Then take any function of your intrest and trying figuring out what its doing. Again you can use printf or any debugger.
Jun 5 '07 #2

dumparun
P: 26
Little OffTopic, but just for the sake of Information

HOW to Prevent Reverse Engineering (mainly for Java programs)

Code Obfuscation. This is done mainly through variable renaming

Suppression of End Of Line Characters. This makes the code difficult to parse.

Use of anonymous classes for handling events. This seems not to be handled by many Decompiler

Class file encryption. This implies some overhead for uncyphering at runtime.

Replacing the method names with certain characters e.g '/' or '.' in the class header causes the popular decompilation tools such as JAD to dump the source code which is incomprehensible (you cannot determine the control flow from the source). (case for JAVA)
Jun 5 '07 #3

blazedaces
100+
P: 284
I have been given the happy task of attempting to document software which only has sparse doxygen comments throughout. I have identified an entry point (first class/method called) and vaguely sketched out UML activity and class diagrams which is an on-going process in the attempt to understand the code structure and processes. I do have other developers to throw my questions to but I don't think I have comprehended enough of the code to have got to that point yet.

It's mainly an unstructured approach that I'm taking, as I haven't had a lot of practice in doing this. My question is, can anyone suggest an approach one might take when handed source code, to firstly understand the processes and structures within, and secondly to generate documentation from it. If a uniform approach does exist, I'd like to try it out here!

Additionally, could anyone suggest a URL (or URLs) which may have this sort of information.

thanks.
Take it step by step. Do one method at a time. In every method, document the input parameters, what is returned, and what might be thrown (exceptions). Then try and describe what happens as clearly and as detailed as possible. If you don't understand a called method look up the class online (if it doesn't exist online it's probably a part of your code/project.

As you begin to describe different methods you should begin to notice patterns (make note of them in the documentation even!) Things like overloaded methods and reasons why methods exist, why they were implimented in this way. It'll start out as bits and pieces. It's like your putting together a puzzle, but slowly you can start to fill in the gaps.

I've never done what you're suggesting, but I've never found code hard to understand, and I personally have to learn most of my programming the hard way (simply by looking at how others might have done it, improve upon it because it's almost never very efficient).

I'm sure there are websites out there, have you tried searching via search engines? Just a suggestion.

Good luck dude,

-blazed
Jun 5 '07 #4

weaknessforcats
Expert Mod 5K+
P: 9,197
Let me add to blazedaces since I have done this.

The approach blazedaces suggests is workable. I suggest to checkout other people's documentation, like Microsoft MSDN or Platform SDK, to get a feel as to how methods and classes are documented.

Know your audience. Most likely these will be developers so your topics have to include information needed by a technical person.

Develop a topic documentation template using your word processor. Create all topics in the same format. Be sure your doc design supports hyperlinks. If this goes on a web page be sure you use an appropriate editor.
Jun 5 '07 #5

P: 4
Thanks to all who replied, your suggestions have been very helpful, and informative (re: java reverse engineering).
I was doing something like what blazedaces suggested, but maybe in too large steps. I'll try the "one method at a time" approach.

thanks again!
Jun 5 '07 #6

AdrianH
Expert 100+
P: 1,251
Thanks to all who replied, your suggestions have been very helpful, and informative (re: java reverse engineering).
I was doing something like what blazedaces suggested, but maybe in too large steps. I'll try the "one method at a time" approach.

thanks again!
Sorry I'm late. ;)

You said you have UML sketches? What type are they? They could be invaluable way of understanding what is going on.


Adrian
Jun 6 '07 #7

P: 4
Sorry I'm late. ;)

You said you have UML sketches? What type are they? They could be invaluable way of understanding what is going on.


Adrian
I've sketched out a UML activity diagram to understand the execution process and a static structure of the system to help with understanding how things fit together. I'm using visual basic's debugger to help with the activity diagram.
Jun 7 '07 #8

AdrianH
Expert 100+
P: 1,251
I've sketched out a UML activity diagram to understand the execution process and a static structure of the system to help with understanding how things fit together. I'm using visual basic's debugger to help with the activity diagram.
As long as you got everything under control. Good luck.


Adrian
Jun 7 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.