Reputation: 206518
I am about to starting to work on a project which involves refactoring and modifying existing code which is in c & c++. The code is a bloated one and is in huge volume. Of course since the code needs to be modified, an understanding of the code has to be developed and in a very short span of time since we have some pretty time pressed project schedule. Can anyone please suggest any open source tools which will help in achieving the above. In short what I am looking for is tool which can:
Please do tell me about any experiences,preferences or favorites worth looking out for.
[EDIT] Came up with a list of tools to help in above. Here's the list:
Graphviz & doxygen
Generate UML class diagrams from existing code base
UMLStudio
Creating an object model for your OO legacy code is the best approach to analysing, understanding and maintaining it. UMLStudio can automatically convert C++, Java, CORBA IDL, PHP 5, and Ada 95 code into OOA&D notation faster than any other CASE tool.
CodeDrawer for C++
The CodeDrawer converts source code to visual based diagrams. Class, struct, and any elements of source code can be shown diagrams. It also shows the logics of a function and a method. The CodeDrawer helps understand source code of your project
Imagix
Reverse engineering and visualization of source code lead to improved program comprehension. Speeds:
Learning Unfamiliar Code
Change Impact Analysis
Integrating Open Source Code
Code Reuse
Software Maintenance
AgileJ AgileJ StructureViews is a plug-in for the Eclipse Java IDE which generates highly customisable UML class diagrams on an industrial scale, ideal for agile development or exploration of any existing Java codebase.
MaintainJ If you can run the code base then MaintainJ generates UML sequence and class diagrams at runtime when you run a particular use case.
Java Reverse Engineering Tool Generates class diagrams and relations between classes from Java source code.
Source Insight Great source browsing software
One more, Thanks to Steve Townsend
Klocwork
Upvotes: 21
Views: 8213
Reputation: 8583
Upvotes: 2
Reputation: 11
5 agilej (http://www.agilej.com/) AgileJ StructureViews is a plug-in for the Eclipse Java IDE which generates highly customisable UML class diagrams on an industrial scale, ideal for agile development or exploration of any existing Java codebase.
AgileJ applies to your points 1 (reverse engineering to help understand the design) and 3 (Good code browsing tools to study the existing code base). Bloated code that has been rapidly slapped together generally shows up as things like:
There are plenty more traits which can be added to this list but the above are made more obvious on a class diagram.
Upvotes: 0
Reputation: 30248
I just thought I'd add a note that CTAGS/ECTAGS is very useful when studying/refactoring an unknown codebase, especially when using a tool like Emacs/CEDET.
Upvotes: 1
Reputation: 95324
There are very few tools that can parse and transform C and C++ code. As a first step, parsing of these languages is considered hard all by itself. Another key problem is the preprocessor, which is used pretty abusively (e.g., not in a structured way) in C programs and makes it difficult for a parser to see the program structure, and consequently difficult for an analyzer (needed to decide when refactorings are legal) to do its analysis correctly.
Modulo these glitches, our DMS Software Reengineering Toolkit can be configured to carry out refactorings on C and C++ code. DMS has industrial strength parsers for C and C++ and uniquely can capture most preprocessor uses as part of the internal code structures (typically people trying to parse C/C++ expand the preprocessor directives away, and that isn't an option for refactoring).
We've used it to carry out massive code reorganizations on C++ code (where preprocessor abuse is minimal because C++ has a variety of other ways to configure code). We also done some automated reengineering of C systems, but with somewhat more effort to handle the abusive preprocessor uses.
What it is not is interactive. You have to plan the refactoring transformations and specify them with a pattern matching language. But it is reliable.
Upvotes: 2
Reputation: 54138
The first question you should ask is 'how do I make sure any changes we make do not break the system?'. Yet your question does not mention tests at all. That's a red flag to me.
I agree with others that tools are not the solution (not likely to turn up in the form you want, not likely to be 100% trustworthy on their own).
Your goal should be to quickly identify the area(s) to be changed - I would do this via inspection and running the code (preferably in existing tests - do you have them?), and make sure you have comprehensive unit and system test coverage on them before you touch a single line. Without that base, you are going to be flying blind and deadlines are way more at risk.
At the very least, if you don't have good tests, communicate this concern to your line upfront so that if things go pear-shaped you are seen to have raised the issue.
You could look at something like this - not used myself though: Klokwork Architect
Upvotes: 4
Reputation: 69672
The code is a bloated one and is in huge volume. Ofcourse since the code needs to be modified an understanding of the code has to be developed and in a very short span of time since we have some pretty time pressed project schedule.
Then you have a management problem : if you already know you have little time to UNDERSTAND a lot of code, you're doomed. To understand this code, you'll have to make it run and go through it and it will take time. Tools will just give you a big map of things but will not show you the real path.
Suitable tool which can auto refactor code with minimal efforts.
You're living in wonderland.
There are tools that gives you the structural architecture of you application, but that will not really help without going through each module one by one and read the code. First the code that use the modules, then the code inside the modules.
The fact that it's C and C++ makes it even harder to define the time that it will take you as it's also relative to the knowledge you have of those languages and the level of knowledge of the people who wrote the app.
Upvotes: 10