views:

479

answers:

8

Hello,

I got a task related to ANCIENT C++ project which hasn't any documentation, comments at all and all code/variables is written in foreign language. Do I have a chance to analyze this code in a 1 working day and make a design/UML to create new features? I have been sitting around for 3 hours already and I feel so frustrated... Maybe somebody also had same problem? Any advice?

BR,

+7  A: 

I suspect the biggest issue may be the fact that it's in a foreign language. You can use various static code analysis tools to try and understand what's going on, but if everything is presented in an unfamiliar language then that's still no use. Your first step (I believe) is to find someone who can speak this language and get them to translate as you go...

Brian Agnew
And/or make liberal use of http://translate.google.com and search-and-replace. But it's so easy to go wrong when translating one word...
T.J. Crowder
+1, without translating variables it's more of the reverse engineering-like experience rather than analysis ;-)
Michael Krelin - hacker
+6  A: 

1) Use Doxygen , You can configure doxygen to extract the code structure from undocumented source files.

2) Use source Insight, Source Insight is an advanced code editor and browser with built-in analysis for C/C++, C#, and Java programs

sat
+3  A: 

Under this time constraint (1 day) it may or may not be doable depending on the size of the project - if its a few hundred lines of code then for sure. If its a serious project with several tens of thousands code lines, then likely no.

The first thing you need to know is what is this program supposed to do at all. If you have no idea what it does and how it does it, then analyzing the code will give you the answer but it will be a long and frustrating task. So my first suggestion would be to get yourself familiar with the outer workings of the software - what does it supposed to do and generally how it is supposed to do it. If you are doing it as part as your work then you should be able to get someone to walk you through using the program - even if its UI is in a foreign language (which I hope it doesn't, even if the code is written by a foreign language speaker).

Once you know what the software is attempting to do, then it should be fairly straight forward (even if lengthy and daunting) to rewrite all the comments in your own language for you to understand. I suggest doing so in a bottoms-up approach: its easier to understand the small and trivial things a program does, then to understand the top-level logic - and a lot of trivial things in order make up the logic of the software.

Only once you understand - to a large degree, anyway - the inner workings of the program you may write its functional spec and work on features.

Guss
+1  A: 

I was quite happy with a tool called Understand (15-day eval license available) for this kind of task. However, I agree with Guss that the time you'll need depends a lot on the size of the code, and one day is probably just enough for a small program.

fvu
+2  A: 

Non-free way on Windows: You can use CppDepend. This application is able to parse your visual project or your source files. It gives you a lot of information like dependency trees. You can try the trial (Maybe it will be enough for what you have to do).

Free way multi-platform: You can use doxygen with a special configuration (extract code structure from undocumented code) and analyze the result.

Patrice Bernassola
+4  A: 

Short answer, no - you probably don't have a chance to understand the code in one day. Reading/maintaining code is one of the hardest things to do, especially when it's lacking documentation. The fact that the code is in a foreign language (!) makes it even harder.

Sounds like you are on a very restricted (unrealistic) time-budget, but Working With Legacy Software is a good book if you're working with legacy systems. If you are planning to keep adding new features to the legacy system it's your responsibility to make your management aware of the scope of the operation. Or at least try.

larsm
Last I dive into new code, it took me about 3 days to have a high-level, very incomplete understanding of how it works.The one before that took me about 2 weeks or so for me to feel really comfortable to do things in.I've also seen some pretty nasty C++, with no/useless comment, and that's just insane to try and learn in a month. And the OP's given a day?
Calyth
A: 

cscope & ctags are a must when I do my own code, and even more when looking to other's code.

piotr
A: 

You may also try this ::

http://www.sgvsarc.com/product%5Fcrystalflow.htm

Malkocoglu